[issue26204] compiler: ignore constants used as statements? (don't emit LOAD_CONST+POP_TOP)

STINNER Victor report at bugs.python.org
Mon Feb 8 12:23:07 EST 2016


STINNER Victor added the comment:

changeset:   100192:4bdb21380743
tag:         tip
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Mon Feb 08 18:17:58 2016 +0100
files:       Lib/test/test_ast.py Lib/test/test_code.py Lib/test/test_grammar.py Misc/NEWS Python/compile.c
description:
compiler now ignores constant statements

The compile ignores constant statements and emit a SyntaxWarning warning.

Don't emit the warning for string statement because triple quoted string is a
common syntax for multiline comments.

Don't emit the warning on ellipis neither: 'def f(): ...' is a legit syntax for
abstract functions.

Changes:

* test_ast: ignore SyntaxWarning when compiling test statements. Modify
  test_load_const() to use assignment expressions rather than constant
  expression.
* test_code: add more kinds of constant statements, ignore SyntaxWarning when
  testing that the compiler removes constant statements.
* test_grammar: ignore SyntaxWarning on the statement "1"

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26204>
_______________________________________


More information about the Python-bugs-list mailing list