Skip to content

Commit

Permalink
tests: Add test for recursive iternext stack overflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgeorge committed Jun 3, 2015
1 parent 953c23b commit 80f638f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/misc/recursive_iternext.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This tests that recursion with iternext doesn't lead to segfault.

try:
x = (1, 2)
for i in range(1000):
x = enumerate(x)
tuple(x)
except RuntimeError:
print("RuntimeError")

try:
x = (1, 2)
for i in range(1000):
x = filter(None, x)
tuple(x)
except RuntimeError:
print("RuntimeError")

try:
x = (1, 2)
for i in range(1000):
x = map(max, x, ())
tuple(x)
except RuntimeError:
print("RuntimeError")

try:
x = (1, 2)
for i in range(1000):
x = zip(x)
tuple(x)
except RuntimeError:
print("RuntimeError")
4 changes: 4 additions & 0 deletions tests/misc/recursive_iternext.py.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RuntimeError
RuntimeError
RuntimeError
RuntimeError

0 comments on commit 80f638f

Please sign in to comment.