diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-02-08 22:45:06 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-02-08 22:45:06 +0100 |
commit | 5ceba03e1af31e79d9dc3492bf109538f804f12b (patch) | |
tree | 191a116d367e85d95322718b1dd9195ae8fb4148 /Python/compile.c | |
parent | f5e1ba6ec857e9dd9dceac208c153cf055f3ba87 (diff) | |
download | cpython-5ceba03e1af31e79d9dc3492bf109538f804f12b.tar.gz |
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/compile.c')
-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 84b79a2fff..ca1d8656c7 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; |