diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-02-08 21:45:06 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-02-08 21:45:06 (GMT) |
commit | 15a3095d64e96d0fe7448270f2c5b0bf22f9c4e1 (patch) | |
tree | da112b21f47896fd48d61ac70429cf5001d89f90 /Python | |
parent | 896632ea6b2b03815ae948aea05972b4e51247ed (diff) | |
download | cpython-15a3095d64e96d0fe7448270f2c5b0bf22f9c4e1.zip cpython-15a3095d64e96d0fe7448270f2c5b0bf22f9c4e1.tar.gz cpython-15a3095d64e96d0fe7448270f2c5b0bf22f9c4e1.tar.bz2 |
compiler: don't emit SyntaxWarning on const stmt
Issue #26204: the compiler doesn't emit SyntaxWarning warnings anymore when
constant statements are ignored.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/compile.c | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/Python/compile.c b/Python/compile.c index 84b79a2..ca1d865 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2619,33 +2619,13 @@ compiler_visit_stmt_expr(struct compiler *c, expr_ty value) switch (value->kind) { case Str_kind: + case Num_kind: case Ellipsis_kind: - /* Issue #26204: ignore string statement, but don't emit a - * SyntaxWarning. Triple quoted strings is a common syntax for - * multiline comments. - * - * Don't emit warning on "def f(): ..." neither. It's a legit syntax - * for abstract function. */ - return 1; - case Bytes_kind: - case Num_kind: case NameConstant_kind: case Constant_kind: - { - PyObject *msg = PyUnicode_FromString("ignore constant statement"); - if (msg == NULL) - return 0; - if (PyErr_WarnExplicitObject(PyExc_SyntaxWarning, - msg, - c->c_filename, c->u->u_lineno, - NULL, NULL) == -1) { - Py_DECREF(msg); - return 0; - } - Py_DECREF(msg); + /* ignore constant statement */ return 1; - } default: break; |