1# Tests that the correct nested exception handler is used when 2# throwing into a generator (previously failed on native emitter). 3 4def gen(): 5 try: 6 yield 1 7 try: 8 yield 2 9 try: 10 yield 3 11 except Exception: 12 yield 4 13 print(0) 14 yield 5 15 except Exception: 16 yield 6 17 print(1) 18 yield 7 19 except Exception: 20 yield 8 21 print(2) 22 yield 9 23 24for i in range(1, 10): 25 g = gen() 26 try: 27 for _ in range(i): 28 print(next(g)) 29 print(g.throw(ValueError)) 30 except ValueError: 31 print('ValueError') 32 except StopIteration: 33 print('StopIteration') 34