-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
py/bc: Fix size calculation of UNWIND_JUMP opcode in mp_opcode_format.
Prior to this patch mp_opcode_format would calculate the incorrect size of the MP_BC_UNWIND_JUMP opcode, missing the additional byte. But, because opcodes below 0x10 are unused and treated as bytes in the .mpy load/save and freezing code, this bug did not show any symptoms, since nested unwind jumps would rarely (if ever) reach a depth of 16 (so the extra byte of this opcode would be between 0x01 and 0x0f and be correctly loaded/saved/frozen simply as an undefined opcode). This patch fixes this bug by correctly accounting for the additional byte. .
- Loading branch information
Showing
4 changed files
with
83 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# test deep unwind via break from nested try-except (22 of them) | ||
while True: | ||
print(1) | ||
try: | ||
try: | ||
try: | ||
try: | ||
try: | ||
try: | ||
try: | ||
try: | ||
try: | ||
try: | ||
try: | ||
try: | ||
try: | ||
try: | ||
try: | ||
try: | ||
try: | ||
try: | ||
try: | ||
try: | ||
try: | ||
try: | ||
print(2) | ||
break | ||
print(3) | ||
except: | ||
pass | ||
except: | ||
pass | ||
except: | ||
pass | ||
except: | ||
pass | ||
except: | ||
pass | ||
except: | ||
pass | ||
except: | ||
pass | ||
except: | ||
pass | ||
except: | ||
pass | ||
except: | ||
pass | ||
except: | ||
pass | ||
except: | ||
pass | ||
except: | ||
pass | ||
except: | ||
pass | ||
except: | ||
pass | ||
except: | ||
pass | ||
except: | ||
pass | ||
except: | ||
pass | ||
except: | ||
pass | ||
except: | ||
pass | ||
except: | ||
pass | ||
except: | ||
pass | ||
print(4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
1 | ||
2 | ||
4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters