]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-144307: Fix a reference leak during module teardown (GH-144308) (GH-144327) 3.14
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 29 Jan 2026 19:19:14 +0000 (20:19 +0100)
committerGitHub <noreply@github.com>
Thu, 29 Jan 2026 19:19:14 +0000 (19:19 +0000)
gh-144307: Fix a reference leak during module teardown (GH-144308)
(cherry picked from commit 219b7ac9d562701bbde21d7e17845c4942b83338)

Signed-off-by: Yongtao Huang <yongtaoh2022@gamil.com>
Co-authored-by: Yongtao Huang <yongtaoh2022@gmail.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 9ae5e06702370ef4c9f3d2505a1332c222366cb0..6963635213a09071f0e7376ac091b0b2036945cd 100644 (file)
@@ -1601,6 +1601,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);