From be59d1489bdf150e05e67a89cc772628af7e8fd6 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 27 Jan 2016 00:39:12 +0100 Subject: 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. --- Python/ast.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Python/ast.c') diff --git a/Python/ast.c b/Python/ast.c index ecfc14cdf8..d19546a2f7 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; -- cgit v1.2.1