aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDamien George2019-09-02 13:30:16 +1000
committerDamien George2019-09-02 13:30:16 +1000
commitb29fae0c564bae271f3659563a2a61230dab5def (patch)
treec3df636b7dbbd7dc60a2df33302cb50e5618c8d3 /tests
parentc348e791879e8615347403f541717eb9386fe4ee (diff)
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. .
Diffstat (limited to 'tests')
-rw-r--r--tests/basics/try_except_break.py73
-rw-r--r--tests/basics/try_except_break.py.exp3
2 files changed, 76 insertions, 0 deletions
diff --git a/tests/basics/try_except_break.py b/tests/basics/try_except_break.py
new file mode 100644
index 000000000..a7683f218
--- /dev/null
+++ b/tests/basics/try_except_break.py
@@ -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)
diff --git a/tests/basics/try_except_break.py.exp b/tests/basics/try_except_break.py.exp
new file mode 100644
index 000000000..e8a01cd98
--- /dev/null
+++ b/tests/basics/try_except_break.py.exp
@@ -0,0 +1,3 @@
+1
+2
+4