[3.8] bpo-37034: Display argument name on errors with keyword arguments with Argument Clinic. (GH-13593). (GH-15599)
(cherry picked from commit 4901fe274bc82b95dc89bcb3de8802a3dfedab32)
Co-authored-by: Rémi Lapeyre <remi.lapeyre@henki.fr>
diff --git a/Python/clinic/bltinmodule.c.h b/Python/clinic/bltinmodule.c.h
index abed6cc..49608cc 100644
--- a/Python/clinic/bltinmodule.c.h
+++ b/Python/clinic/bltinmodule.c.h
@@ -102,7 +102,7 @@
goto skip_optional;
}
if (!PyUnicode_Check(args[1])) {
- _PyArg_BadArgument("format", 2, "str", args[1]);
+ _PyArg_BadArgument("format", "argument 2", "str", args[1]);
goto exit;
}
if (PyUnicode_READY(args[1]) == -1) {
@@ -200,7 +200,7 @@
goto exit;
}
if (!PyUnicode_Check(args[2])) {
- _PyArg_BadArgument("compile", 3, "str", args[2]);
+ _PyArg_BadArgument("compile", "argument 'mode'", "str", args[2]);
goto exit;
}
Py_ssize_t mode_length;
@@ -849,4 +849,4 @@
exit:
return return_value;
}
-/*[clinic end generated code: output=e173df340a9e4516 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=1927f3c9abd00c35 input=a9049054013a1b77]*/
diff --git a/Python/clinic/import.c.h b/Python/clinic/import.c.h
index 05e3106..743d002 100644
--- a/Python/clinic/import.c.h
+++ b/Python/clinic/import.c.h
@@ -92,12 +92,12 @@
goto exit;
}
if (!PyObject_TypeCheck(args[0], &PyCode_Type)) {
- _PyArg_BadArgument("_fix_co_filename", 1, (&PyCode_Type)->tp_name, args[0]);
+ _PyArg_BadArgument("_fix_co_filename", "argument 1", (&PyCode_Type)->tp_name, args[0]);
goto exit;
}
code = (PyCodeObject *)args[0];
if (!PyUnicode_Check(args[1])) {
- _PyArg_BadArgument("_fix_co_filename", 2, "str", args[1]);
+ _PyArg_BadArgument("_fix_co_filename", "argument 2", "str", args[1]);
goto exit;
}
if (PyUnicode_READY(args[1]) == -1) {
@@ -156,7 +156,7 @@
PyObject *name;
if (!PyUnicode_Check(arg)) {
- _PyArg_BadArgument("init_frozen", 0, "str", arg);
+ _PyArg_BadArgument("init_frozen", "argument", "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@@ -188,7 +188,7 @@
PyObject *name;
if (!PyUnicode_Check(arg)) {
- _PyArg_BadArgument("get_frozen_object", 0, "str", arg);
+ _PyArg_BadArgument("get_frozen_object", "argument", "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@@ -220,7 +220,7 @@
PyObject *name;
if (!PyUnicode_Check(arg)) {
- _PyArg_BadArgument("is_frozen_package", 0, "str", arg);
+ _PyArg_BadArgument("is_frozen_package", "argument", "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@@ -252,7 +252,7 @@
PyObject *name;
if (!PyUnicode_Check(arg)) {
- _PyArg_BadArgument("is_builtin", 0, "str", arg);
+ _PyArg_BadArgument("is_builtin", "argument", "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@@ -284,7 +284,7 @@
PyObject *name;
if (!PyUnicode_Check(arg)) {
- _PyArg_BadArgument("is_frozen", 0, "str", arg);
+ _PyArg_BadArgument("is_frozen", "argument", "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@@ -433,7 +433,7 @@
goto exit;
}
if (!PyBuffer_IsContiguous(&source, 'C')) {
- _PyArg_BadArgument("source_hash", 2, "contiguous buffer", args[1]);
+ _PyArg_BadArgument("source_hash", "argument 'source'", "contiguous buffer", args[1]);
goto exit;
}
return_value = _imp_source_hash_impl(module, key, &source);
@@ -454,4 +454,4 @@
#ifndef _IMP_EXEC_DYNAMIC_METHODDEF
#define _IMP_EXEC_DYNAMIC_METHODDEF
#endif /* !defined(_IMP_EXEC_DYNAMIC_METHODDEF) */
-/*[clinic end generated code: output=b51244770fdcf4b8 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ff06f7cf4b73eb76 input=a9049054013a1b77]*/
diff --git a/Python/clinic/marshal.c.h b/Python/clinic/marshal.c.h
index ab45753..05d4830 100644
--- a/Python/clinic/marshal.c.h
+++ b/Python/clinic/marshal.c.h
@@ -152,7 +152,7 @@
goto exit;
}
if (!PyBuffer_IsContiguous(&bytes, 'C')) {
- _PyArg_BadArgument("loads", 0, "contiguous buffer", arg);
+ _PyArg_BadArgument("loads", "argument", "contiguous buffer", arg);
goto exit;
}
return_value = marshal_loads_impl(module, &bytes);
@@ -165,4 +165,4 @@
return return_value;
}
-/*[clinic end generated code: output=ae2bca1aa239e095 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a859dabe8b0afeb6 input=a9049054013a1b77]*/
diff --git a/Python/clinic/sysmodule.c.h b/Python/clinic/sysmodule.c.h
index 563332e..93bc332 100644
--- a/Python/clinic/sysmodule.c.h
+++ b/Python/clinic/sysmodule.c.h
@@ -228,7 +228,7 @@
PyObject *s;
if (!PyUnicode_Check(arg)) {
- _PyArg_BadArgument("intern", 0, "str", arg);
+ _PyArg_BadArgument("intern", "argument", "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@@ -931,7 +931,7 @@
}
func = args[0];
if (!PyTuple_Check(args[1])) {
- _PyArg_BadArgument("call_tracing", 2, "tuple", args[1]);
+ _PyArg_BadArgument("call_tracing", "argument 2", "tuple", args[1]);
goto exit;
}
funcargs = args[1];
@@ -1088,4 +1088,4 @@
#ifndef SYS_GETANDROIDAPILEVEL_METHODDEF
#define SYS_GETANDROIDAPILEVEL_METHODDEF
#endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */
-/*[clinic end generated code: output=1a67b37c4486d65f input=a9049054013a1b77]*/
+/*[clinic end generated code: output=092edc868de055a6 input=a9049054013a1b77]*/
diff --git a/Python/clinic/traceback.c.h b/Python/clinic/traceback.c.h
index 2815f65..04daf2a 100644
--- a/Python/clinic/traceback.c.h
+++ b/Python/clinic/traceback.c.h
@@ -32,7 +32,7 @@
}
tb_next = fastargs[0];
if (!PyObject_TypeCheck(fastargs[1], &PyFrame_Type)) {
- _PyArg_BadArgument("TracebackType", 2, (&PyFrame_Type)->tp_name, fastargs[1]);
+ _PyArg_BadArgument("TracebackType", "argument 'tb_frame'", (&PyFrame_Type)->tp_name, fastargs[1]);
goto exit;
}
tb_frame = (PyFrameObject *)fastargs[1];
@@ -59,4 +59,4 @@
exit:
return return_value;
}
-/*[clinic end generated code: output=7e4c0e252d0973b0 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=3def6c06248feed8 input=a9049054013a1b77]*/