1# test with handling within a viper function 2 3 4class C: 5 def __init__(self): 6 print("__init__") 7 8 def __enter__(self): 9 print("__enter__") 10 11 def __exit__(self, a, b, c): 12 print("__exit__", a, b, c) 13 14 15# basic with 16@micropython.viper 17def f(): 18 with C(): 19 print(1) 20 21 22f() 23 24# nested with and try-except 25@micropython.viper 26def f(): 27 try: 28 with C(): 29 print(1) 30 fail 31 print(2) 32 except NameError: 33 print("NameError") 34 35 36f() 37