summaryrefslogtreecommitdiff
path: root/tests/micropython/opt_level_lineno.py
blob: fcfbe8643da1ec307065a13b27160976f840ba03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# test micropython.opt_level() and line numbers

try:
    import micropython
except ImportError:
    print("SKIP")
    raise SystemExit

# 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()
""")