mirror of
https://github.com/python/cpython.git
synced 2025-07-19 17:25:54 +00:00
[3.8] bpo-37034: Display argument name on errors with keyword arguments with Argument Clinic. (GH-13593). (GH-15599)
(cherry picked from commit 4901fe274b
)
Co-authored-by: Rémi Lapeyre <remi.lapeyre@henki.fr>
This commit is contained in:
parent
9db66a2b5a
commit
96631dcb11
62 changed files with 623 additions and 553 deletions
|
@ -610,24 +610,18 @@ convertitem(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
|||
|
||||
|
||||
|
||||
/* Format an error message generated by convertsimple(). */
|
||||
/* Format an error message generated by convertsimple().
|
||||
displayname must be UTF-8 encoded.
|
||||
*/
|
||||
|
||||
void
|
||||
_PyArg_BadArgument(const char *fname, int iarg,
|
||||
_PyArg_BadArgument(const char *fname, const char *displayname,
|
||||
const char *expected, PyObject *arg)
|
||||
{
|
||||
if (iarg) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s() argument %d must be %.50s, not %.50s",
|
||||
fname, iarg, expected,
|
||||
arg == Py_None ? "None" : arg->ob_type->tp_name);
|
||||
}
|
||||
else {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s() argument must be %.50s, not %.50s",
|
||||
fname, expected,
|
||||
arg == Py_None ? "None" : arg->ob_type->tp_name);
|
||||
}
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s() %.200s must be %.50s, not %.50s",
|
||||
fname, displayname, expected,
|
||||
arg == Py_None ? "None" : arg->ob_type->tp_name);
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue