cpython: b3c2472c12a1 (original) (raw)

Mercurial > cpython

changeset 88637:b3c2472c12a1 3.3

Issue #20317: Don't create a reference loop in ExitStack [#20317]

Nick Coghlan ncoghlan@gmail.com
date Wed, 22 Jan 2014 22:24:46 +1000
parents 1b89fd73c625
children 46c3ea358784 b26db63bb931
files Lib/contextlib.py Lib/test/test_contextlib.py Misc/NEWS
diffstat 3 files changed, 38 insertions(+), 1 deletions(-)[+] [-] Lib/contextlib.py 10 Lib/test/test_contextlib.py 23 Misc/NEWS 6

line wrap: on

line diff

--- a/Lib/contextlib.py +++ b/Lib/contextlib.py @@ -231,11 +231,19 @@ class ExitStack(object): # we were actually nesting multiple with statements frame_exc = sys.exc_info()[1] def _fix_exception_context(new_exc, old_exc):

# Callbacks are invoked in LIFO order to match the behaviour of

--- a/Lib/test/test_contextlib.py +++ b/Lib/test/test_contextlib.py @@ -600,6 +600,29 @@ class TestExitStack(unittest.TestCase): else: self.fail("Expected KeyError, but no exception was raised")

+

+ + def test_body_exception_suppress(self): def suppress_exc(*exc_details): return True

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -50,6 +50,12 @@ Core and Builtins Library ------- +- Issue #20317: ExitStack.exit could create a self-referential loop if an