Implement Python 3.8 && 3.9 try-except-finally logic #493
+319
−36
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add tests for simple cases of try-except-finally (rename one old Python 2.6 test);
Implement
JUMP_IF_NOT_EXC_MATCH_A
with a fakeCMP_EXCEPTION
followed by aPOP_JUMP_IF_TRUE
;Implement
BEGIN_FINALLY
with a fakeLOAD_CONST_A None
;Implement Python 3.8+ specific
SETUP_FINALLY_A
handling both EXCEPT and FINALLY cases. We guess which is which by looking at the targeted block that seems to either be aPOP_TOP
or aDUP_TOP
in the case of an EXCEPT block;Implement
RERAISE
with a fakeEND_FINALLY
;In Python 3.9+, emulate a
BEGIN_FINALLY
whenPOP_BLOCK
is not followed by aJUMP_FORWARD_A
(maybe source of bugs);In Python 3.9+, skip the duplicated code from the FINALLY blocks with a jump in bytecode and a fake
END_FINALLY
.