Close #14963: Use an iterative algorithm in contextlib.ExitStack.__exit__ (Patch by Alon Horev)

This commit is contained in:
Nick Coghlan 2012-06-01 00:00:38 +10:00
parent c73e8c2830
commit a5bd2a18ce
3 changed files with 29 additions and 28 deletions

View file

@ -572,6 +572,12 @@ class TestExitStack(unittest.TestCase):
stack.push(lambda *exc: 1/0)
stack.push(lambda *exc: {}[1])
def test_excessive_nesting(self):
# The original implementation would die with RecursionError here
with ExitStack() as stack:
for i in range(10000):
stack.callback(int)
def test_instance_bypass(self):
class Example(object): pass
cm = Example()