New submission from Ned Batchelder <[EMAIL PROTECTED]>: When tracing line execution with sys.settrace, a particular code structure fails to report an executed line. The line is a continue statement after an if condition in which the if condition is true every time it is executed.
Attached is a file with two copies of the same code, except in the first the if condition is always true, and in the second it is sometimes true. In the first, trace.py reports that the continue is never executed, even though it is (as evidenced from the values of a, b, and c after execution). In the second code, the continue is properly reported. This bug has been present since version 2.3. 2.2 does not exhibit it (trace.py didn't exist in 2.2, but coverage.py shows the problem also). To see the problem, execute "trace.py -c -m continue.py". Then continue.py.cover will show: 1: a = b = c = 0 101: for n in range(100): 100: if n % 2: 50: if n % 4: 50: a += 1 >>>>>> continue else: 50: b += 1 50: c += 1 1: assert a == 50 and b == 50 and c == 50 1: a = b = c = 0 101: for n in range(100): 100: if n % 2: 50: if n % 3: 33: a += 1 17: continue else: 50: b += 1 50: c += 1 1: assert a == 33 and b == 50 and c == 50 ---------- components: Interpreter Core files: continue.py messages: 64692 nosy: nedbat severity: normal status: open title: Line tracing of continue after always-taken if is incorrect type: behavior versions: Python 2.3, Python 2.4, Python 2.5, Python 2.6 Added file: http://bugs.python.org/file9888/continue.py __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2506> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com