diff --git a/Lib/contextlib.py b/Lib/contextlib.py index 5b646fabca0225..f5bdf9b0e409a2 100644 --- a/Lib/contextlib.py +++ b/Lib/contextlib.py @@ -164,7 +164,9 @@ def __exit__(self, typ, value, traceback): # Suppress StopIteration *unless* it's the same exception that # was passed to throw(). This prevents a StopIteration # raised inside the "with" statement from being suppressed. - return exc is not value + result = exc is not value + del exc, value # avoid cyclic reference + return result except RuntimeError as exc: # Don't re-raise the passed in exception. (issue27122) if exc is value: