From: Guido van Rossum Date: Sun, 27 Apr 2014 17:33:58 +0000 (-0700) Subject: asyncio: Be careful accessing instance variables in __del__ (closes #21340). X-Git-Tag: v3.4.1rc1~22 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=83c1ddda469e7a99f11afc7d6758b3d80ad9aa3b;p=python asyncio: Be careful accessing instance variables in __del__ (closes #21340). --- diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py index c6c22dd29f..e8ee947501 100644 --- a/Lib/asyncio/tasks.py +++ b/Lib/asyncio/tasks.py @@ -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__