Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(29181)

Unified Diff: Lib/test/test_builtin.py

Issue 14010: deeply nested filter segfaults
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Lib/test/test_itertools.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_builtin.py Tue Mar 19 13:27:24 2013 +0200
+++ b/Lib/test/test_builtin.py Tue Mar 19 20:08:58 2013 +0200
@@ -636,6 +636,16 @@
f2 = filter(filter_char, "abcdeabcde")
self.check_iter_pickle(f1, list(f2))
+ def test_filter_deep_recursion(self):
+ # Issue #14010
+ it = (0, 1)
+ for _ in range(1000000):
+ it = filter(bool, it)
+ with self.assertRaises(RuntimeError):
+ for _ in it:
+ pass
+ del it
+
def test_getattr(self):
self.assertTrue(getattr(sys, 'stdout') is sys.stdout)
self.assertRaises(TypeError, getattr, sys, 1)
@@ -834,6 +844,16 @@
m2 = map(map_char, "Is this the real life?")
self.check_iter_pickle(m1, list(m2))
+ def test_map_deep_recursion(self):
+ # Issue #14010
+ it = (0, 1)
+ for _ in range(1000000):
+ it = map(int, it)
+ with self.assertRaises(RuntimeError):
+ for _ in it:
+ pass
+ del it
+
def test_max(self):
self.assertEqual(max('123123'), '3')
self.assertEqual(max(1, 2, 3), 3)
@@ -1407,6 +1427,16 @@
z1 = zip(a, b)
self.check_iter_pickle(z1, t)
+ def test_zip_deep_recursion(self):
+ # Issue #14010
+ it = (0, 1)
+ for _ in range(1000000):
+ it = zip(it)
+ with self.assertRaises(RuntimeError):
+ for _ in it:
+ pass
+ del it
+
def test_format(self):
# Test the basic machinery of the format() builtin. Don't test
# the specifics of the various formatters
@@ -1564,8 +1594,40 @@
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)
« no previous file with comments | « no previous file | Lib/test/test_itertools.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+