2018-04-01 17:15:35 +00:00
|
|
|
# test deeply recursive generators
|
|
|
|
|
2018-04-10 04:39:51 +00:00
|
|
|
# simple "yield from" recursion
|
2018-04-01 17:15:35 +00:00
|
|
|
def gen():
|
|
|
|
yield from gen()
|
2020-03-23 02:26:08 +00:00
|
|
|
|
|
|
|
|
2018-04-01 17:15:35 +00:00
|
|
|
try:
|
|
|
|
list(gen())
|
|
|
|
except RuntimeError:
|
2020-03-23 02:26:08 +00:00
|
|
|
print("RuntimeError")
|
2018-04-10 04:39:51 +00:00
|
|
|
|
|
|
|
# recursion via an iterator over a generator
|
|
|
|
def gen2():
|
|
|
|
for x in gen2():
|
|
|
|
yield x
|
2020-03-23 02:26:08 +00:00
|
|
|
|
|
|
|
|
2018-04-10 04:39:51 +00:00
|
|
|
try:
|
|
|
|
next(gen2())
|
|
|
|
except RuntimeError:
|
2020-03-23 02:26:08 +00:00
|
|
|
print("RuntimeError")
|