[3.14] gh-144307: Fix a reference leak during module teardown (GH-144308) (GH-144327)

gh-144307: Fix a reference leak during module teardown (GH-144308)
(cherry picked from commit 219b7ac9d5)

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>
This commit is contained in:
Miss Islington (bot) 2026-01-29 20:19:14 +01:00 committed by GitHub
parent de1b2cce30
commit 49ce23f2d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 0 deletions

View 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);