Skip to content

Commit 3c72c3a

Browse files
committed
tests/micropython/opt_level_lineno.py: Force test func to use bytecode.
So that the test can run the same on all targets when used with the native emitter. Signed-off-by: Damien George <damien@micropython.org>
1 parent 95d1794 commit 3c72c3a

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

tests/micropython/opt_level_lineno.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,15 @@
33
# check that level 3 doesn't store line numbers
44
# the expected output is that any line is printed as "line 1"
55
micropython.opt_level(3)
6-
exec("try:\n xyz\nexcept NameError as er:\n import sys\n sys.print_exception(er)")
6+
7+
# force bytecode emitter, because native emitter doesn't store line numbers
8+
exec("""
9+
@micropython.bytecode
10+
def f():
11+
try:
12+
xyz
13+
except NameError as er:
14+
import sys
15+
sys.print_exception(er)
16+
f()
17+
""")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Traceback (most recent call last):
2-
File "<string>", line 1, in <module>
2+
File "<string>", line 1, in f
33
NameError: name 'xyz' isn't defined

tests/run-tests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ def open(self, path, mode):
131131
"misc/print_exception.py",
132132
"micropython/emg_exc.py",
133133
"micropython/heapalloc_traceback.py",
134-
"micropython/opt_level_lineno.py",
135134
"thread/thread_exc2.py",
136135
# These require stack-allocated slice optimisation.
137136
"micropython/heapalloc_slice.py",

0 commit comments

Comments
 (0)