circuitpython/tests/micropython/opt_level_lineno.py
Damien George 3c72c3a1e6 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>
2025-08-15 00:36:27 +10:00

17 lines
396 B
Python

import micropython as micropython
# check that level 3 doesn't store line numbers
# the expected output is that any line is printed as "line 1"
micropython.opt_level(3)
# force bytecode emitter, because native emitter doesn't store line numbers
exec("""
@micropython.bytecode
def f():
try:
xyz
except NameError as er:
import sys
sys.print_exception(er)
f()
""")