On Mon, Feb 8, 2016 at 9:44 AM Victor Stinner <victor.stinner at gmail.com> wrote: > Hi, > > I changed the Python compiler to ignore any kind "constant > expressions", whereas it only ignored strings and integers before: > http://bugs.python.org/issue26204 > > The compiler now also emits a SyntaxWarning on such case. IMHO the > warning can help to detect bugs for developers who just learnt Python. > > The warning is *not* emited for strings, since triple quoted strings > are a common syntax for multiline comments. > > The warning is *not* emited neither for ellispis (...) since "f(): > ..." is a legit syntax for abstract function. > > Are you ok with the new warning? > I'm +1 on this. -gps > > > New behaviour: > > haypo at smithers$ ./python > Python 3.6.0a0 (default:759a975e1230, Feb 8 2016, 18:21:23) > >>> def f(): > ... False > ... > <stdin>:2: SyntaxWarning: ignore constant statement > > >>> import dis; dis.dis(f) > 2 0 LOAD_CONST 0 (None) > 3 RETURN_VALUE > > > Old behaviour: > > haypo at smithers$ python3 > Python 3.4.3 (default, Jun 29 2015, 12:16:01) > >>> def f(): > ... False > ... > >>> import dis; dis.dis(f) > 2 0 LOAD_CONST 1 (False) > 3 POP_TOP > 4 LOAD_CONST 0 (None) > 7 RETURN_VALUE > > > > Before strings and numbers were already ignored. Example: > > haypo at smithers$ python3 > Python 3.4.3 (default, Jun 29 2015, 12:16:01) > > >>> def f(): > ... 123 > ... > >>> import dis; dis.dis(f) > 2 0 LOAD_CONST 0 (None) > 3 RETURN_VALUE > > > Victor > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > https://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: > https://mail.python.org/mailman/options/python-dev/greg%40krypto.org > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20160208/427e18c1/attachment-0001.html>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4