summaryrefslogtreecommitdiffstats
path: root/Python/ast.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-01-26 23:39:12 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-01-26 23:39:12 (GMT)
commitbe59d1489bdf150e05e67a89cc772628af7e8fd6 (patch)
tree5e4677069edcb4609bf746163477f950e42b86c0 /Python/ast.c
parent25219f596a069e8d4ed7114cd9b1bddc2a1de3b7 (diff)
downloadcpython-be59d1489bdf150e05e67a89cc772628af7e8fd6.zip
cpython-be59d1489bdf150e05e67a89cc772628af7e8fd6.tar.gz
cpython-be59d1489bdf150e05e67a89cc772628af7e8fd6.tar.bz2
Issue #26146: enhance ast.Constant error message
Mention the name of the invalid type in error message of AST validation for constants. Suggestion made by Joseph Jevnik on a review.
Diffstat (limited to 'Python/ast.c')
-rw-r--r--Python/ast.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Python/ast.c b/Python/ast.c
index ecfc14c..d19546a 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -288,7 +288,9 @@ 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_SetString(PyExc_TypeError, "invalid type in Constant");
+ PyErr_Format(PyExc_TypeError,
+ "got an invalid type in Constant: %s",
+ Py_TYPE(exp->v.Constant.value)->tp_name);
return 0;
}
return 1;