2018-04-01 13:15:35 -04:00
|
|
|
# test deeply recursive generators
|
|
|
|
|
2018-04-10 00:39:51 -04:00
|
|
|
# simple "yield from" recursion
|
2018-04-01 13:15:35 -04:00
|
|
|
def gen():
|
|
|
|
yield from gen()
|
2021-03-15 09:57:36 -04:00
|
|
|
|
|
|
|
|
2018-04-01 13:15:35 -04:00
|
|
|
try:
|
|
|
|
list(gen())
|
|
|
|
except RuntimeError:
|
2021-03-15 09:57:36 -04:00
|
|
|
print("RuntimeError")
|
2018-04-10 00:39:51 -04:00
|
|
|
|
|
|
|
# recursion via an iterator over a generator
|
|
|
|
def gen2():
|
|
|
|
for x in gen2():
|
|
|
|
yield x
|
2021-03-15 09:57:36 -04:00
|
|
|
|
|
|
|
|
2018-04-10 00:39:51 -04:00
|
|
|
try:
|
|
|
|
next(gen2())
|
|
|
|
except RuntimeError:
|
2021-03-15 09:57:36 -04:00
|
|
|
print("RuntimeError")
|