mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-40000: Improve error messages when validating invalid ast.Constant nodes (GH-19055)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
This commit is contained in:
parent
50e6e99178
commit
0ac59f93c0
3 changed files with 16 additions and 3 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue