]> granicus.if.org Git - python/commitdiff
asyncio: Be careful accessing instance variables in __del__ (closes #21340).
authorGuido van Rossum <guido@python.org>
Sun, 27 Apr 2014 17:33:58 +0000 (10:33 -0700)
committerGuido van Rossum <guido@python.org>
Sun, 27 Apr 2014 17:33:58 +0000 (10:33 -0700)
Lib/asyncio/tasks.py

index c6c22dd29f2ba0f339633e7f956785313762cecc..e8ee947501df557c1d609c8d73440f980e0070d7 100644 (file)
@@ -76,7 +76,9 @@ class CoroWrapper:
         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__