Bug in "sys.settrace" ??

Lothar Scholz llothar at web.de
Wed Feb 18 20:07:39 EST 2004


I use sys.settrace in my console application to stop any endless loop
but in the following loop:

a = 0
while 1:
	a = a + 1

the trace function is only called 4 times, but in code 

a = 0
while 1:
    a = a + 1
    print a

the trace function is called infinite times. So i assume that there is
a bug in the first case. I think that the system assumes that it must
not call the trace function again because it is always the same line
number, and the optimizer removes the "while 1" line.



More information about the Python-list mailing list