gh-83004: Clean up refleak in _io initialisation (GH-98840)

(cherry picked from commit 1208037246)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2022-11-06 06:03:52 -08:00 committed by GitHub
parent d025046ef5
commit 29c3dc050a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View file

@ -0,0 +1 @@
Clean up refleak on failed module initialisation in :mod:`_io`.

View file

@ -703,10 +703,10 @@ PyInit__io(void)
goto fail;
/* BlockingIOError, for compatibility */
Py_INCREF(PyExc_BlockingIOError);
if (PyModule_AddObject(m, "BlockingIOError",
(PyObject *) PyExc_BlockingIOError) < 0)
if (PyModule_AddObjectRef(m, "BlockingIOError",
(PyObject *) PyExc_BlockingIOError) < 0) {
goto fail;
}
// Set type base classes
PyFileIO_Type.tp_base = &PyRawIOBase_Type;