This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author nedbat
Recipients nedbat
Date 2008-03-29.13:38:39
SpamBayes Score 0.046717115
Marked as misclassified No
Message-id <1206797921.05.0.258043023613.issue2506@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2008-03-29 13:38:41nedbatsetspambayes_score: 0.0467171 -> 0.046717115
recipients: + nedbat
2008-03-29 13:38:41nedbatsetspambayes_score: 0.0467171 -> 0.0467171
messageid: <1206797921.05.0.258043023613.issue2506@psf.upfronthosting.co.za>
2008-03-29 13:38:40nedbatlinkissue2506 messages
2008-03-29 13:38:39nedbatcreate