Bug in "sys.settrace" ??

L

Lothar Scholz

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.
 
B

Ben Finney

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

As presented, we can't know how you're using sys.settrace, nor how this
code relates to the rest of the program.

Please show a complete, minimal example that shows the behaviour you're
experiencing. This will do a few things:

- We'll be able to see what you're seeing, unless the problem is
somehow dependent on your computer.
- You'll cut away any code that doesn't relate to the problem (hint:
keep cutting until the problem doesn't appear).
- In reducing the problem to its essentials, you will gain more
insight into what is actually happening, and possibly solve it
yourself.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top