Close #14963: Use an iterative algorithm in contextlib.ExitStack.__exit__ (Patch by Alon Horev)
diff --git a/Lib/test/test_contextlib.py b/Lib/test/test_contextlib.py
index e5eed21..efa9dcb 100644
--- a/Lib/test/test_contextlib.py
+++ b/Lib/test/test_contextlib.py
@@ -572,6 +572,12 @@
             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()