Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
I'm experimenting with the new monitoring interface in PEP 669. The LINE event happens multiple times for the line in the body of a for loop (as I expect), but the for statement itself only gets an event on entering, not each time around the loop.
This code:
importsysdefloop3():foriinrange(3):print(i)print("done")the_code=loop3.__code__defline_callback(code,line_number):assertcode==the_codeprint(f"LINE:{line_number}")my_id=sys.monitoring.COVERAGE_IDsys.monitoring.use_tool_id(my_id,"repro")sys.monitoring.register_callback(my_id,sys.monitoring.events.LINE,line_callback)sys.monitoring.set_local_events(my_id,the_code,sys.monitoring.events.LINE)loop3()
produces:
LINE: 4LINE: 50LINE: 51LINE: 52LINE: 6doneI would expect Line 4 to be monitored after each "LINE: 5", including after the last one.
This is with commit263abd3 of CPython.