← index #6836PR #6690
Off-topic · high · value 0.076
QUERY · ISSUE

sys.settrace issue (bug?)

openby wolfc01opened 2021-02-03updated 2024-09-13
needs-info

Hi,

when I have the following code

def test():
	for a in range(10):
		if a == 7:
			print("it worked")	
			print("again")	
			print("or not.")	
			
test()

then sys.settrace fires at the line containing print("or not.") even if the condition a==7 is False.

for the debugger I am writing, see https://github.com/wolfc01/micropython_debugger/blob/main/debugger.py

Probably this has to do with entering or leaving some local scope?

When I run the very same debugger and example in python 3, above effect does not occur.

Best regards
Carl.

CANDIDATE · PULL REQUEST

RFC tests: Make settrace test work on a wider range of machines.

closedby stinosopened 2020-12-10updated 2020-12-18
tests

Depending on type and version of installation the CPython output
can include 'zipimport' as well, next to the 'importlib' frames.
And on Windows the path reduction needs to deal with the different
path separator.

RFC part: this isn't completely ready yet in that the path reduction logic will still fail when running tests like

run-tests -d .\misc

because then there's no tests/misc in the path at all.
Also the current logic in sys_settrace_loop.py and sys_settrace_generator.py isn't actually needed I think, because co_filename isn't a full path in those tests.
Does this need fixing?

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied