summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/compile.c8
-rw-r--r--Python/symtable.c5
2 files changed, 11 insertions, 2 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 6ad3822..7d5ada6 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -2223,6 +2223,14 @@ compiler_assert(struct compiler *c, stmt_ty s)
if (assertion_error == NULL)
return 0;
}
+ if (s->v.Assert.test->kind == Tuple_kind &&
+ asdl_seq_LEN(s->v.Assert.test->v.Tuple.elts) > 0) {
+ const char* msg =
+ "assertion is always true, perhaps remove parentheses?";
+ if (PyErr_WarnExplicit(PyExc_SyntaxWarning, msg, c->c_filename,
+ c->u->u_lineno, NULL, NULL) == -1)
+ return 0;
+ }
VISIT(c, expr, s->v.Assert.test);
end = compiler_new_block(c);
if (end == NULL)
diff --git a/Python/symtable.c b/Python/symtable.c
index 84d0067..b896c52 100644
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -33,8 +33,9 @@ PySTEntry_New(struct symtable *st, identifier name, _Py_block_ty block,
k = PyLong_FromVoidPtr(key);
if (k == NULL)
goto fail;
- ste = (PySTEntryObject *)PyObject_New(PySTEntryObject,
- &PySTEntry_Type);
+ ste = PyObject_New(PySTEntryObject, &PySTEntry_Type);
+ if (ste == NULL)
+ goto fail;
ste->ste_table = st;
ste->ste_id = k;
ste->ste_tmpname = 0;