Skip to content

Wrongly treat statement as uncovered #694

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

Closed
whoiscc opened this issue Aug 17, 2018 · 1 comment
Closed

Wrongly treat statement as uncovered #694

whoiscc opened this issue Aug 17, 2018 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@whoiscc
Copy link

whoiscc commented Aug 17, 2018

Reproduction:

class A:
    def __init__(self, xs):
        self._xs = xs

    def __getitem__(self, x):
        return x in self._xs


a1 = A([10])
a2 = A(list(range(42)))

for i in range(42):
    for j in range(42):
        if not a1[i] or not a2[j]:
            continue

After running coverage run test.py and coverage report -m:

Name      Stmts   Miss  Cover   Missing
---------------------------------------
test.py      11      1    91%   15

And line 15 is the single continue statement. If I add a print('continue') above it, tons of "continue" will be printed, and coverage report correctly back to 100%.

@nedbat
Copy link
Owner

nedbat commented Aug 17, 2018

This report is a duplicate of #198. It's a limitation of CPython's peephole optimizer, described in https://bugs.python.org/issue2506

@nedbat nedbat closed this as completed Aug 17, 2018
@nedbat nedbat added the duplicate This issue or pull request already exists label 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

2 participants