From: Eric Snow Date: Fri, 31 Mar 2023 18:09:10 +0000 (-0600) Subject: gh-100227: Fix Cleanup of the Extensions Cache (gh-103150) X-Git-Tag: v3.12.0a7~25 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dde028480e57bffa83fb084b15ec22490c42ef93;p=thirdparty%2FPython%2Fcpython.git 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. --- 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; }