[Python-checkins] cpython (merge 3.4 -> default): Merge 3.4 -> default: asyncio: Be careful accessing instance variables in

guido.van.rossum python-checkins at python.org
Sun Apr 27 19:47:39 CEST 2014


http://hg.python.org/cpython/rev/0cb436c6f082
changeset:   90480:0cb436c6f082
parent:      90477:05d162756946
parent:      90478:d42d3d3f9c41
user:        Guido van Rossum <guido at python.org>
date:        Sun Apr 27 10:34:39 2014 -0700
summary:
  Merge 3.4 -> default: asyncio: Be careful accessing instance variables in __del__ (closes #21340).

files:
  Lib/asyncio/tasks.py |  4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)


diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py
--- a/Lib/asyncio/tasks.py
+++ b/Lib/asyncio/tasks.py
@@ -76,7 +76,9 @@
         return self.gen.gi_code
 
     def __del__(self):
-        frame = self.gen.gi_frame
+        # Be careful accessing self.gen.frame -- self.gen might not exist.
+        gen = getattr(self, 'gen', None)
+        frame = getattr(gen, 'gi_frame', None)
         if frame is not None and frame.f_lasti == -1:
             func = self.func
             code = func.__code__

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


More information about the Python-checkins mailing list