From 5ceba03e1af31e79d9dc3492bf109538f804f12b Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 8 Feb 2016 22:45:06 +0100 Subject: compiler: don't emit SyntaxWarning on const stmt Issue #26204: the compiler doesn't emit SyntaxWarning warnings anymore when constant statements are ignored. --- Python/compile.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) (limited to 'Python/compile.c') 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; -- cgit v1.2.1