Skip to content

Commit 4ab9dd5

Browse files
hyongtao-codeblurb-it[bot]
authored andcommitted
gh-144307: Fix a reference leak during module teardown (GH-144308)
(cherry picked from commit 219b7ac) Co-authored-by: Yongtao Huang <yongtaoh2022@gmail.com> Signed-off-by: Yongtao Huang <yongtaoh2022@gamil.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
1 parent de1b2cc commit 4ab9dd5

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Prevent a reference leak in module teardown at interpreter finalization.

Python/pylifecycle.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,6 +1601,7 @@ finalize_remove_modules(PyObject *modules, int verbose)
16011601
PyObject *value = PyObject_GetItem(modules, key);
16021602
if (value == NULL) {
16031603
PyErr_FormatUnraisable("Exception ignored while removing modules");
1604+
Py_DECREF(key);
16041605
continue;
16051606
}
16061607
CLEAR_MODULE(key, value);

0 commit comments

Comments
 (0)