]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-144307: Fix a reference leak during module teardown (GH-144308) (GH-144328) 3.13
authorPeter Bierma <zintensitydev@gmail.com>
Thu, 29 Jan 2026 19:18:39 +0000 (11:18 -0800)
committerGitHub <noreply@github.com>
Thu, 29 Jan 2026 19:18:39 +0000 (19:18 +0000)
(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 bfa1fe4f603682a993a339759e4d618731f4cb72..8ba9b2bd006f02bbf59070a788c704ef7c20a2bd 100644 (file)
@@ -1609,6 +1609,7 @@ finalize_remove_modules(PyObject *modules, int verbose)
                 PyObject *value = PyObject_GetItem(modules, key);
                 if (value == NULL) {
                     PyErr_FormatUnraisable("Exception ignored on removing modules");
+                    Py_DECREF(key);
                     continue;
                 }
                 CLEAR_MODULE(key, value);