-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Open
Labels
Description
Port, board and/or hardware
Pyboard, but probably doesn't matter
MicroPython version
MicroPython v1.25.0-preview.316.g5214d8a29.dirty on 2025-02-14; PYBv1.1 with STM32F405RG
Reproduction
import sys
def add1(x):
return x+1
def foo(x):
return add1(x)+add1(x)
def trace(frame, event, arg):
bcode = []
for b in frame.f_code.co_code:
bcode.append(hex(b))
if event == 'call':
print(f'trace: {event} {frame.f_lineno}:{frame.f_code.co_name} <-from {frame.f_back.f_lineno}:{frame.f_back.f_code.co_name}')
print(f'calling file "{frame.f_code.co_filename}" at line: {frame.f_code.co_firstlineno}')
return
sys.settrace(trace)
foo(42)
sys.settrace(None)
Expected behaviour (CPython)
trace: call 6:foo <-from 20:<module>
calling file "/home/raul/Micropython/settrace_errdemo.py" at line: 6
trace: call 3:add1 <-from 7:foo
calling file "/home/raul/Micropython/settrace_errdemo.py" at line: 3
trace: call 3:add1 <-from 7:foo
calling file "/home/raul/Micropython/settrace_errdemo.py" at line: 3
Observed behaviour (Micropython)
trace: call 6:foo <-from 20:<module>
calling file "settrace_errdemo.py" at line: 7
trace: call 3:add1 <-from 7:foo
calling file "settrace_errdemo.py" at line: 4
trace: call 3:add1 <-from 7:foo
calling file "settrace_errdemo.py" at line: 4
Additional Information
No, I've provided everything above.
Code of Conduct
Yes, I agree