circuitpython/tests/stress/recursive_gen.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
338 B
Python
Raw Normal View History

# test deeply recursive generators
2023-02-01 13:38:41 +05:30
# simple "yield from" recursion
def gen():
yield from gen()
2021-03-15 19:27:36 +05:30
try:
list(gen())
except RuntimeError:
2021-03-15 19:27:36 +05:30
print("RuntimeError")
2023-02-01 13:38:41 +05:30
# recursion via an iterator over a generator
def gen2():
for x in gen2():
yield x
2021-03-15 19:27:36 +05:30
try:
next(gen2())
except RuntimeError:
2021-03-15 19:27:36 +05:30
print("RuntimeError")