[issue2506] Line tracing of continue after always-taken if is incorrect

Jean-Paul Calderone report at bugs.python.org
Wed Jul 13 18:07:51 CEST 2011


Jean-Paul Calderone <invalid at example.invalid> added the comment:

Since the main argument for not fixing this bug seems to be that it doesn't affect many users, it seems like I should comment here that the issue is affecting me.  A recently proposed addition to Twisted gets bitten by this case, resulting in a report of less than full test coverage when in fact the tests do exercise every line and branch of the change.

Perhaps it is too hard to add and maintain a no-optimizations feature for Python (although I agree with Ned that this would be a useful feature for many reasons, not just to fix this bug).  There are other possible solutions to the issue of inaccurate coverage reports though.

For example, Python could provide an API for determining which lines have code that might be executed.  coverage.py (and the stdlib trace.py) currently use the code object's lnotab to decide which lines might be executable.  Maybe that should omit "continue" lines that get jumped over.  If the line will never execute, it seems there is no need to have it in the lnotab.

Using the lnotab is something of a hack though, so it might also make sense to leave it alone but introduce an API to get the same information, but corrected for whatever peephole optimizations the interpreter happens to have.

As far as the "not a bug" arguments go, I don't think it matters much whether you ultimately decide to call it a bug or a feature request.  It *is* clearly a useful feature to some people though, and rejecting the requested behavior as "not a bug" doesn't help anyone.  So call it a feature request if that makes it more palletable. :)

----------
nosy: +exarkun
resolution: wont fix -> 
status: closed -> open

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2506>
_______________________________________


More information about the Python-bugs-list mailing list