mirror of
https://github.com/AdaCore/cpython.git
synced 2026-02-12 12:57:15 -08:00
bpo-36854: Fix refleak in subinterpreter (GH-17331)
finalize_interp_clear() now explicitly clears the codec registry and then trigger a GC collection to clear all references.
This commit is contained in:
@@ -1210,6 +1210,14 @@ finalize_interp_clear(PyThreadState *tstate)
|
||||
{
|
||||
int is_main_interp = _Py_IsMainInterpreter(tstate);
|
||||
|
||||
/* bpo-36854: Explicitly clear the codec registry
|
||||
and trigger a GC collection */
|
||||
PyInterpreterState *interp = tstate->interp;
|
||||
Py_CLEAR(interp->codec_search_path);
|
||||
Py_CLEAR(interp->codec_search_cache);
|
||||
Py_CLEAR(interp->codec_error_registry);
|
||||
_PyGC_CollectNoFail();
|
||||
|
||||
/* Clear interpreter state and all thread states */
|
||||
PyInterpreterState_Clear(tstate->interp);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user