-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
GH-128534: Instrument branches for async for
loops.
#130569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH-128534: Instrument branches for async for
loops.
#130569
Conversation
I think I need some help understanding the bytecode generated. This Python:
Generates this bytecode:
How can execution get to offset 74 (CLEANUP_THROW)? Do I need to examine the exception table? My code understands there is a possible branch from line 17 to 18 because at offset 32, it follows the jump to L6 and looks at offsets 42, 44, 46, 48, which gets to line 18. But it doesn't find the branch from 17 to 19. Offset 32 flows to 36, 38, 40, and back to 32, never leaving line 17. Does this question make sense? |
More information: the two branch events I get are 44 to 46 (NOT_TAKEN to STORE_FAST) and 32 to 80 (SEND to LOAD_GLOBAL due to an exception). I expected the 44->46 event to start from offset 32, since that's the jump-possible instruction that preceded it. Is the event correct? For 32->80 I guess I need to use the exception table. Are SEND instructions special in this way because they can raise StopIteration? Are there other instructions I would need to treat this way? |
Also, I don't see any documented interface to the exception table, though maybe I missed something. If I need to interpret it, what should I do? |
Hmm, never mind, I've figured out what to do about these, and I think this is going to work. |
You shouldn't need to understand the bytecode or exception table. In fact, it looks like we are missing the branches from |
We need a way to map branch destinations back to source code... if |
async for
#128534