]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-144307: Fix a reference leak during module teardown (GH-144308)
authorYongtao Huang <yongtaoh2022@gmail.com>
Thu, 29 Jan 2026 18:50:54 +0000 (02:50 +0800)
committerGitHub <noreply@github.com>
Thu, 29 Jan 2026 18:50:54 +0000 (13:50 -0500)
Signed-off-by: Yongtao Huang <yongtaoh2022@gamil.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Misc/NEWS.d/next/Core_and_Builtins/2026-01-29-02-18-08.gh-issue-144307.CLbm_o.rst [new file with mode: 0644]
Python/pylifecycle.c

diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-29-02-18-08.gh-issue-144307.CLbm_o.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-29-02-18-08.gh-issue-144307.CLbm_o.rst
new file mode 100644 (file)
index 0000000..d6928e6
--- /dev/null
@@ -0,0 +1 @@
+Prevent a reference leak in module teardown at interpreter finalization.
index 88dbdb6d139c5f1f3655132705ba67287adaf0ac..d3ed08de1d15d38a287f00920d1fa9f79798f3ed 100644 (file)
@@ -1622,6 +1622,7 @@ finalize_remove_modules(PyObject *modules, int verbose)
                 PyObject *value = PyObject_GetItem(modules, key);
                 if (value == NULL) {
                     PyErr_FormatUnraisable("Exception ignored while removing modules");
+                    Py_DECREF(key);
                     continue;
                 }
                 CLEAR_MODULE(key, value);