Skip to content

Commit e31e36b

Browse files
committed
Avoid cyclic reference in contextmanager
1 parent f10b7b2 commit e31e36b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Lib/contextlib.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ def __exit__(self, typ, value, traceback):
164164
# Suppress StopIteration *unless* it's the same exception that
165165
# was passed to throw(). This prevents a StopIteration
166166
# raised inside the "with" statement from being suppressed.
167-
return exc is not value
167+
result = exc is not value
168+
del exc, value # avoid cyclic reference
169+
return result
168170
except RuntimeError as exc:
169171
# Don't re-raise the passed in exception. (issue27122)
170172
if exc is value:

0 commit comments

Comments
 (0)