class context:
def __enter__(self):
return "SOMETHING YOU WILL NOT FORGET"
def __exit__(*args):
print("exit called")
return True
def use_context_manager():
with context() as c:
return 2 + 2
# === Result: ===
t = traceur.DummyTrace(use_context_manager)
t.call()
t.do_report()
=== Entering New Frame use_context_manager (11085720) ===
[]
1 LOAD_GLOBAL 0 context
[<class '__main__.context'>]
5 CALL_FUNCTION 0 0
[<__main__.context object at 0x7fd977b9e608>]
9 SETUP_WITH 16 28
['SOMETHING YOU WILL NOT FORGET', <bound method context.__exit__ of <__main__.context object at 0x7fd977b9e608>>]
13 STORE_FAST 0 c
[<bound method context.__exit__ of <__main__.context object at 0x7fd977b9e608>>]
17 LOAD_CONST 2 4
[4, <bound method context.__exit__ of <__main__.context object at 0x7fd977b9e608>>]
21 RETURN_VALUE None None
[8, 4, <bound method context.__exit__ of <__main__.context object at 0x7fd977b9e608>>]
29 WITH_CLEANUP None None
[8, 4]
31 END_FINALLY None None