Skip to content

Commit 80f638f

Browse files
committed
tests: Add test for recursive iternext stack overflow.
1 parent 953c23b commit 80f638f

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

tests/misc/recursive_iternext.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This tests that recursion with iternext doesn't lead to segfault.
2+
3+
try:
4+
x = (1, 2)
5+
for i in range(1000):
6+
x = enumerate(x)
7+
tuple(x)
8+
except RuntimeError:
9+
print("RuntimeError")
10+
11+
try:
12+
x = (1, 2)
13+
for i in range(1000):
14+
x = filter(None, x)
15+
tuple(x)
16+
except RuntimeError:
17+
print("RuntimeError")
18+
19+
try:
20+
x = (1, 2)
21+
for i in range(1000):
22+
x = map(max, x, ())
23+
tuple(x)
24+
except RuntimeError:
25+
print("RuntimeError")
26+
27+
try:
28+
x = (1, 2)
29+
for i in range(1000):
30+
x = zip(x)
31+
tuple(x)
32+
except RuntimeError:
33+
print("RuntimeError")
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
RuntimeError
2+
RuntimeError
3+
RuntimeError
4+
RuntimeError

0 commit comments

Comments
 (0)