summaryrefslogtreecommitdiffstats
path: root/Python/getargs.c
diff options
context:
space:
mode:
authorRĂ©mi Lapeyre <remi.lapeyre@henki.fr>2019-08-29 14:49:08 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2019-08-29 14:49:08 (GMT)
commit4901fe274bc82b95dc89bcb3de8802a3dfedab32 (patch)
tree2e6e4d0b1cdcb499df7f049ebc9dbbdb9f392bbe /Python/getargs.c
parent59725f3badb3028636c8906ecac4ceb0a37f3982 (diff)
downloadcpython-4901fe274bc82b95dc89bcb3de8802a3dfedab32.zip
cpython-4901fe274bc82b95dc89bcb3de8802a3dfedab32.tar.gz
cpython-4901fe274bc82b95dc89bcb3de8802a3dfedab32.tar.bz2
bpo-37034: Display argument name on errors with keyword arguments with Argument Clinic. (GH-13593)
Diffstat (limited to 'Python/getargs.c')
-rw-r--r--Python/getargs.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/Python/getargs.c b/Python/getargs.c
index fe6474c..02a0366 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -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 *