[Python-checkins] bpo-38962: Fix reference leak in the per-subinterpreter gc (GH-17457)

Miss Islington (bot) webhook-mailer at python.org
Wed Dec 4 06:51:09 EST 2019


https://github.com/python/cpython/commit/ac0e1c2694bc199dbd073312145e3c09bee52cc4
commit: ac0e1c2694bc199dbd073312145e3c09bee52cc4
branch: master
author: Pablo Galindo <Pablogsal at gmail.com>
committer: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
date: 2019-12-04T03:51:03-08:00
summary:

bpo-38962: Fix reference leak in the per-subinterpreter gc (GH-17457)



https://bugs.python.org/issue38962



Automerge-Triggered-By: @pablogsal

files:
M Python/pylifecycle.c

diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 9218978cc6fa7..d6f65ec3caf66 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -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) {



More information about the Python-checkins mailing list