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 p-ganssle
Recipients aldwinaldwin, lukasz.langa, miss-islington, ned.deily, nedbat, p-ganssle, pablogsal, serhiy.storchaka, terry.reedy, xtreak
Date 2019-07-05.21:53:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1562363626.36.0.418409271819.issue37500@roundup.psfhosted.org>
In-reply-to
Content
> CPython has acted the current way for about 15 years (since 2.4 was released), and this is the first time anyone has raised an objection. 

This is the expected result of fixing a bug that has been open since 2008 (11 years), which itself was noticed independently, also in 2008 (#1875 and #1920, respectively). I also independently discovered the same issue last year when writing some tests for IPython, and I suspect others have hit it as well and shrugged it off because it's not that hard to work around and there was an open issue for it.

I will also note that this "not raising a SyntaxError" behavior is a CPython-specific implementation detail (and is quite fragile to boot), note:

    $ cat syntax_err.py
    if 0:
        return

    $ python syntax_err.py   # Works on 2.7 and <3.8
    $ pypy syntax_err.py     # Same behavior with pypy3.6
      File "syntax_err.py", line 2
        return
        ^
    SyntaxError: return outside function
    
I am not sure if pypy emits the same bytecode, but I think that


> Please don't break a package as fundamental as coverage.

I think it's a bit melodramatic to consider this "breaking" coverage, particularly since I would find it very weird if any code under an "if 0" were simply *ignored* by coverage, and I would probably report it as a bug. It changes the behavior, sure, but this was code that is legitimately not covered. I don't think it's a big problem to add `# pragma: nocover` to code blocks you don't want covered.
History
Date User Action Args
2019-07-05 21:53:46p-gansslesetrecipients: + p-ganssle, terry.reedy, nedbat, ned.deily, lukasz.langa, serhiy.storchaka, pablogsal, miss-islington, xtreak, aldwinaldwin
2019-07-05 21:53:46p-gansslesetmessageid: <1562363626.36.0.418409271819.issue37500@roundup.psfhosted.org>
2019-07-05 21:53:46p-gansslelinkissue37500 messages
2019-07-05 21:53:46p-gansslecreate