]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-100227: Fix Cleanup of the Extensions Cache (gh-103150)
authorEric Snow <ericsnowcurrently@gmail.com>
Fri, 31 Mar 2023 18:09:10 +0000 (12:09 -0600)
committerGitHub <noreply@github.com>
Fri, 31 Mar 2023 18:09:10 +0000 (12:09 -0600)
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.

Python/import.c

index a45b3bfaacb25246176a58c4c9ce0a115a4c8d5a..24249ae4a6ade192cb420889728f32a78be0a0af 100644 (file)
@@ -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;
 }