bpo-37034: Display argument name on errors with keyword arguments with Argument Clinic. (GH-13593)

This commit is contained in:
Rémi Lapeyre 2019-08-29 16:49:08 +02:00 committed by Serhiy Storchaka
parent 59725f3bad
commit 4901fe274b
62 changed files with 623 additions and 553 deletions

View file

@ -99,7 +99,7 @@ bytes_partition(PyBytesObject *self, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&sep, 'C')) {
_PyArg_BadArgument("partition", 0, "contiguous buffer", arg);
_PyArg_BadArgument("partition", "argument", "contiguous buffer", arg);
goto exit;
}
return_value = bytes_partition_impl(self, &sep);
@ -142,7 +142,7 @@ bytes_rpartition(PyBytesObject *self, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&sep, 'C')) {
_PyArg_BadArgument("rpartition", 0, "contiguous buffer", arg);
_PyArg_BadArgument("rpartition", "argument", "contiguous buffer", arg);
goto exit;
}
return_value = bytes_rpartition_impl(self, &sep);
@ -420,14 +420,14 @@ bytes_maketrans(void *null, PyObject *const *args, Py_ssize_t nargs)
goto exit;
}
if (!PyBuffer_IsContiguous(&frm, 'C')) {
_PyArg_BadArgument("maketrans", 1, "contiguous buffer", args[0]);
_PyArg_BadArgument("maketrans", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (PyObject_GetBuffer(args[1], &to, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&to, 'C')) {
_PyArg_BadArgument("maketrans", 2, "contiguous buffer", args[1]);
_PyArg_BadArgument("maketrans", "argument 2", "contiguous buffer", args[1]);
goto exit;
}
return_value = bytes_maketrans_impl(&frm, &to);
@ -480,14 +480,14 @@ bytes_replace(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs)
goto exit;
}
if (!PyBuffer_IsContiguous(&old, 'C')) {
_PyArg_BadArgument("replace", 1, "contiguous buffer", args[0]);
_PyArg_BadArgument("replace", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (PyObject_GetBuffer(args[1], &new, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&new, 'C')) {
_PyArg_BadArgument("replace", 2, "contiguous buffer", args[1]);
_PyArg_BadArgument("replace", "argument 2", "contiguous buffer", args[1]);
goto exit;
}
if (nargs < 3) {
@ -568,7 +568,7 @@ bytes_decode(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, PyObj
}
if (args[0]) {
if (!PyUnicode_Check(args[0])) {
_PyArg_BadArgument("decode", 1, "str", args[0]);
_PyArg_BadArgument("decode", "argument 'encoding'", "str", args[0]);
goto exit;
}
Py_ssize_t encoding_length;
@ -585,7 +585,7 @@ bytes_decode(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, PyObj
}
}
if (!PyUnicode_Check(args[1])) {
_PyArg_BadArgument("decode", 2, "str", args[1]);
_PyArg_BadArgument("decode", "argument 'errors'", "str", args[1]);
goto exit;
}
Py_ssize_t errors_length;
@ -674,7 +674,7 @@ bytes_fromhex(PyTypeObject *type, PyObject *arg)
PyObject *string;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("fromhex", 0, "str", arg);
_PyArg_BadArgument("fromhex", "argument", "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@ -755,4 +755,4 @@ skip_optional_pos:
exit:
return return_value;
}
/*[clinic end generated code: output=2d0a3733e13e753a input=a9049054013a1b77]*/
/*[clinic end generated code: output=dbed3c3ff6faa382 input=a9049054013a1b77]*/