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? New behaviour: haypo@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@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@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@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com