[Python-checkins] gh-100227: Fix Cleanup of the Extensions Cache (gh-103150)

ericsnowcurrently webhook-mailer at python.org
Fri Mar 31 14:09:18 EDT 2023


https://github.com/python/cpython/commit/dde028480e57bffa83fb084b15ec22490c42ef93
commit: dde028480e57bffa83fb084b15ec22490c42ef93
branch: main
author: Eric Snow <ericsnowcurrently at gmail.com>
committer: ericsnowcurrently <ericsnowcurrently at gmail.com>
date: 2023-03-31T12:09:10-06:00
summary:

gh-100227: Fix Cleanup of the Extensions Cache (gh-103150)

Decref the key in the right interpreter in _extensions_cache_set().

This is a follow-up to gh-103084. I found the bug while working on gh-101660.

files:
M Python/import.c

diff --git a/Python/import.c b/Python/import.c
index a45b3bfaacb2..24249ae4a6ad 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -983,13 +983,13 @@ _extensions_cache_set(PyObject *filename, PyObject *name, PyModuleDef *def)
     res = 0;
 
 finally:
+    Py_XDECREF(key);
     if (oldts != NULL) {
         _PyThreadState_Swap(interp->runtime, oldts);
         _PyThreadState_UnbindDetached(main_tstate);
         Py_DECREF(name);
         Py_DECREF(filename);
     }
-    Py_XDECREF(key);
     extensions_lock_release();
     return res;
 }



More information about the Python-checkins mailing list