diff options
author | Shantanu <12621235+hauntsaninja@users.noreply.github.com> | 2022-11-03 14:29:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-03 14:29:11 (GMT) |
commit | 1208037246eeab4c5c003f1651edfefb045e6fb7 (patch) | |
tree | 2504907189f87ad2a93d88924e41956aa32d032e | |
parent | 8c4de57de9842a5330e8b8f18b02bd6865ce59bb (diff) | |
download | cpython-1208037246eeab4c5c003f1651edfefb045e6fb7.zip cpython-1208037246eeab4c5c003f1651edfefb045e6fb7.tar.gz cpython-1208037246eeab4c5c003f1651edfefb045e6fb7.tar.bz2 |
gh-83004: Clean up refleak in _io initialisation (#98840)
-rw-r--r-- | Misc/NEWS.d/next/Library/2022-11-02-05-52-36.gh-issue-83004.LBl79O.rst | 1 | ||||
-rw-r--r-- | Modules/_io/_iomodule.c | 6 |
2 files changed, 4 insertions, 3 deletions
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 index 0000000..4de17ab --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-11-02-05-52-36.gh-issue-83004.LBl79O.rst @@ -0,0 +1 @@ +Clean up refleak on failed module initialisation in :mod:`_io`. diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c index 38ef246..a7b2e98 100644 --- a/Modules/_io/_iomodule.c +++ b/Modules/_io/_iomodule.c @@ -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; |