◐ Shell
clean mode source ↗

Message 297189 - Python tracker

Actually I just finished reading njs's blog post, and as he points out that special case for SETUP_FINALLY is basically broken.  There are other cases where it doesn't really work either.  For example if you have:

if ...:
    do_something()
else:
    do_something_else()
try:
    ...
finally:
    ...

then (ignoring the issue about POP_TOP for a moment) the last instruction in *one* of these branches if followed immediately by SETUP_FINALLY, while in the other branch there's a JUMP_FORWARD, then the SETUP_FINALLY.

All the more reason for a more generic solution to this that doesn't depend strictly on the next op locally in the byte code.