circuitpython/tests/basics/gen_stack_overflow.py
Jeff Epler a909007fef py/objgenerator: Check stack before resuming a generator
This turns a hard crash in a recursive generator into
a 'maximum recursion depth exceeded' exception.
2018-04-01 16:40:15 -05:00

8 lines
108 B
Python

def gen():
yield from gen()
try:
print(list(gen()))
except RuntimeError:
print("RuntimeError")