[Python-checkins] cpython (merge 3.5 -> default): merge 3.5 (#27812)

benjamin.peterson python-checkins at python.org
Mon Sep 5 13:41:13 EDT 2016


https://hg.python.org/cpython/rev/1d7a938b1e47
changeset:   103046:1d7a938b1e47
parent:      103044:125cf99907c7
parent:      103045:3e4452424f9b
user:        Benjamin Peterson <benjamin at python.org>
date:        Mon Sep 05 10:40:34 2016 -0700
summary:
  merge 3.5 (#27812)

files:
  Misc/NEWS           |  3 +++
  Objects/genobject.c |  5 ++++-
  2 files changed, 7 insertions(+), 1 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -29,6 +29,9 @@
 - Issue #27506: Support passing the bytes/bytearray.translate() "delete"
   argument by keyword.
 
+- Issue #27812: Properly clear out a generator's frame's backreference to the
+  generator to prevent crashes in frame.clear().
+
 - Issue #27811: Fix a crash when a coroutine that has not been awaited is
   finalized with warnings-as-errors enabled.
 
diff --git a/Objects/genobject.c b/Objects/genobject.c
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -71,7 +71,10 @@
         return;                     /* resurrected.  :( */
 
     _PyObject_GC_UNTRACK(self);
-    Py_CLEAR(gen->gi_frame);
+    if (gen->gi_frame != NULL) {
+        gen->gi_frame->f_gen = NULL;
+        Py_CLEAR(gen->gi_frame);
+    }
     Py_CLEAR(gen->gi_code);
     Py_CLEAR(gen->gi_name);
     Py_CLEAR(gen->gi_qualname);

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list