circuitpython/tests/basics/generator-exc.py
Paul Sokolovsky c0abc28aa1 objgenerator: Keep exception stack within generator object, like value stack.
This is required to properly handle exceptions across yields.
2014-03-22 17:55:42 +02:00

12 lines
217 B
Python

# Test proper handling of exceptions within generator across yield
def gen():
try:
yield 1
raise ValueError
except ValueError:
print("Caught")
yield 2
for i in gen():
print(i)