mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
Issue #14010: Fix a crash when iterating or deleting deeply nested filters
(builting and in itertools module, i.e. map(), itertools.chain(), etc).
This commit is contained in:
parent
e16f4dc80a
commit
e8f706eda7
6 changed files with 225 additions and 15 deletions
|
@ -1565,8 +1565,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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue