Skip to content

Commit

Permalink
bpo-38962: Fix reference leak in the per-subinterpreter gc (pythonGH-…
Browse files Browse the repository at this point in the history
  • Loading branch information
pablogsal authored and miss-islington committed Dec 4, 2019
1 parent b96c6b0 commit ac0e1c2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1253,17 +1253,16 @@ 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);

/* Trigger a GC collection on subinterpreters*/
if (!is_main_interp) {
_PyGC_CollectNoFail();
}

finalize_interp_types(tstate, is_main_interp);

if (is_main_interp) {
Expand Down

0 comments on commit ac0e1c2

Please sign in to comment.