Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect coverage on continue statement #254

Closed
nedbat opened this issue Aug 13, 2013 · 2 comments
Closed

Incorrect coverage on continue statement #254

nedbat opened this issue Aug 13, 2013 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@nedbat
Copy link
Owner

nedbat commented Aug 13, 2013

Originally reported by Andrew Svetlov (Bitbucket: asvetlov, GitHub: asvetlov)


When I've tried to make coverage for code like this:

#!python
def f(a):
    while True:
        a -= 1
        if a==0:
            pass
        else:
            continue
        break

f(2)

I'd got report that line with continue statement is never executed. That's definitely not true.

I used branched coverage:
coverage3 run --branch cov.py
coverage3 html

I'd got this problem when had worked on tulip, minimal stripped example that I published can reproduce error easy.
Looks like tracer actually has never called with line for 'continue', that's how python works.

Thoughts?


@nedbat
Copy link
Owner Author

nedbat commented Aug 13, 2013

Andrew, unfortunately this is an artifact of the peephole optimizer.

If you believe as I do that it would be useful to have a way to disable the peephole optimizer so that these sorts of analyses would give useful results, comment on this CPython ticket: http://bugs.python.org/issue2506 "Add mechanism to disable optimizations".

@nedbat
Copy link
Owner Author

nedbat commented Aug 13, 2013

Duplicate of #198.

@nedbat nedbat closed this as completed Aug 13, 2013
@nedbat nedbat added major bug Something isn't working labels Jun 23, 2018
@nedbat nedbat added duplicate This issue or pull request already exists and removed bug Something isn't working major labels Aug 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

1 participant