summaryrefslogtreecommitdiff
path: root/Python/ast.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/ast.c')
-rw-r--r--Python/ast.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Python/ast.c b/Python/ast.c
index 2e9a8d05f7..2b74ed4dbd 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -147,6 +147,11 @@ validate_constant(PyObject *value)
return 1;
}
+ if (!PyErr_Occurred()) {
+ PyErr_Format(PyExc_TypeError,
+ "got an invalid type in Constant: %s",
+ _PyType_Name(Py_TYPE(value)));
+ }
return 0;
}
@@ -261,9 +266,6 @@ validate_expr(expr_ty exp, expr_context_ty ctx)
validate_keywords(exp->v.Call.keywords);
case Constant_kind:
if (!validate_constant(exp->v.Constant.value)) {
- PyErr_Format(PyExc_TypeError,
- "got an invalid type in Constant: %s",
- _PyType_Name(Py_TYPE(exp->v.Constant.value)));
return 0;
}
return 1;