Skip to content

Commit ac0e1c2

Browse files
pablogsalmiss-islington
authored andcommitted
bpo-38962: Fix reference leak in the per-subinterpreter gc (GH-17457)
https://bugs.python.org/issue38962 Automerge-Triggered-By: @pablogsal
1 parent b96c6b0 commit ac0e1c2

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Python/pylifecycle.c

+5-6
Original file line numberDiff line numberDiff line change
@@ -1253,17 +1253,16 @@ finalize_interp_clear(PyThreadState *tstate)
12531253
{
12541254
int is_main_interp = _Py_IsMainInterpreter(tstate);
12551255

1256-
/* bpo-36854: Explicitly clear the codec registry
1257-
and trigger a GC collection */
12581256
PyInterpreterState *interp = tstate->interp;
1259-
Py_CLEAR(interp->codec_search_path);
1260-
Py_CLEAR(interp->codec_search_cache);
1261-
Py_CLEAR(interp->codec_error_registry);
1262-
_PyGC_CollectNoFail();
12631257

12641258
/* Clear interpreter state and all thread states */
12651259
PyInterpreterState_Clear(tstate->interp);
12661260

1261+
/* Trigger a GC collection on subinterpreters*/
1262+
if (!is_main_interp) {
1263+
_PyGC_CollectNoFail();
1264+
}
1265+
12671266
finalize_interp_types(tstate, is_main_interp);
12681267

12691268
if (is_main_interp) {

0 commit comments

Comments
 (0)