summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_builtin.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-04-06 18:20:30 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-04-06 18:20:30 (GMT)
commitaac81e2780a181f4076190a28cde3e4bfaab614b (patch)
tree1886a2923e5959ce59f294558ba2122c3497366c /Lib/test/test_builtin.py
parentc53fd51278fe37a8d57968267452bf06d8db609c (diff)
parente8f706eda77db200728fc436dca20f0591eeec27 (diff)
downloadcpython-aac81e2780a181f4076190a28cde3e4bfaab614b.zip
cpython-aac81e2780a181f4076190a28cde3e4bfaab614b.tar.gz
cpython-aac81e2780a181f4076190a28cde3e4bfaab614b.tar.bz2
Issue #14010: Fix a crash when iterating or deleting deeply nested filters
(builting and in itertools module, i.e. map(), itertools.chain(), etc).
Diffstat (limited to 'Lib/test/test_builtin.py')
-rw-r--r--Lib/test/test_builtin.py34
1 files changed, 33 insertions, 1 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index f46f8d5..b601ea4 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -1564,8 +1564,40 @@ class TestSorted(unittest.TestCase):
data = 'The quick Brown fox Jumped over The lazy Dog'.split()
self.assertRaises(TypeError, sorted, data, None, lambda x,y: 0)
+class TestRecursionLimit(unittest.TestCase):
+ # Issue #14010
+ recursionlimit = sys.getrecursionlimit()
+
+ def test_filter(self):
+ it = (0, 1)
+ for _ in range(self.recursionlimit):
+ it = filter(bool, it)
+ with self.assertRaises(RuntimeError):
+ for _ in it:
+ pass
+ del it
+
+ def test_map(self):
+ it = (0, 1)
+ for _ in range(self.recursionlimit):
+ it = map(int, it)
+ with self.assertRaises(RuntimeError):
+ for _ in it:
+ pass
+ del it
+
+ def test_zip(self):
+ it = (0, 1)
+ for _ in range(self.recursionlimit):
+ it = zip(it)
+ with self.assertRaises(RuntimeError):
+ for _ in it:
+ pass
+ del it
+
+
def test_main(verbose=None):
- test_classes = (BuiltinTest, TestSorted)
+ test_classes = (BuiltinTest, TestSorted, TestRecursionLimit)
run_unittest(*test_classes)