Paul Ganssle <p.gans...@gmail.com> added the comment:

> 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.

----------
nosy: +p-ganssle

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37500>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to