]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-83004: Clean up refleak in _io initialisation (GH-98840)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 3 Nov 2022 14:58:44 +0000 (07:58 -0700)
committerGitHub <noreply@github.com>
Thu, 3 Nov 2022 14:58:44 +0000 (07:58 -0700)
(cherry picked from commit 1208037246eeab4c5c003f1651edfefb045e6fb7)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Misc/NEWS.d/next/Library/2022-11-02-05-52-36.gh-issue-83004.LBl79O.rst [new file with mode: 0644]
Modules/_io/_iomodule.c

diff --git a/Misc/NEWS.d/next/Library/2022-11-02-05-52-36.gh-issue-83004.LBl79O.rst b/Misc/NEWS.d/next/Library/2022-11-02-05-52-36.gh-issue-83004.LBl79O.rst
new file mode 100644 (file)
index 0000000..4de17ab
--- /dev/null
@@ -0,0 +1 @@
+Clean up refleak on failed module initialisation in :mod:`_io`.
index 170dea41e8abdd2093aed569b622ef02b7408fe5..9e53de59c9cf73399cc41613b7e3508cac2b7b86 100644 (file)
@@ -718,10 +718,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;
+    }
 
     /* Concrete base types of the IO ABCs.
        (the ABCs themselves are declared through inheritance in io.py)