mirror of
https://github.com/python/cpython.git
synced 2025-07-10 04:45:36 +00:00
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.
This commit is contained in:
parent
25219f596a
commit
be59d1489b
2 changed files with 9 additions and 1 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue