[issue1875] "if 0: return" not raising SyntaxError

Stéphane Wirtel report at bugs.python.org
Tue May 14 10:22:36 EDT 2019


Stéphane Wirtel <stephane at wirtel.be> added the comment:

With the last 2.7 and 3.7, I can import the x module and the 'hello' is automatically printed.

Python 2.7.15 (default, Oct 15 2018, 15:26:09) 
[GCC 8.2.1 20180801 (Red Hat 8.2.1-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import x
hello


Python 3.7.3 (default, Apr  2 2019, 06:55:20) 
[GCC 8.3.1 20190223 (Red Hat 8.3.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import x
hello

>>> content = open('x.py').read()
>>> import dis
>>> dis.dis(content)
  1           0 LOAD_NAME                0 (print)
              2 LOAD_CONST               0 ('hello')
              4 CALL_FUNCTION            1
              6 POP_TOP

  3           8 LOAD_CONST               1 (None)
             10 RETURN_VALUE


but because I am not sure about this issue, I prefer to ask Serhiy.

Can we close it?

Thank you

----------
nosy: +matrixise, serhiy.storchaka
versions: +Python 3.7, Python 3.8 -Python 2.7, Python 3.3, Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue1875>
_______________________________________


More information about the Python-bugs-list mailing list