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

diff --git a/Objects/clinic/bytearrayobject.c.h b/Objects/clinic/bytearrayobject.c.h
index 08c6eb5..ad8ed7e 100644
--- a/Objects/clinic/bytearrayobject.c.h
+++ b/Objects/clinic/bytearrayobject.c.h
@@ -115,14 +115,14 @@
         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 = bytearray_maketrans_impl(&frm, &to);
@@ -175,14 +175,14 @@
         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) {
@@ -735,7 +735,7 @@
     }
     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;
@@ -752,7 +752,7 @@
         }
     }
     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;
@@ -854,7 +854,7 @@
     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) {
@@ -1011,4 +1011,4 @@
 {
     return bytearray_sizeof_impl(self);
 }
-/*[clinic end generated code: output=7848247e5469ba1b input=a9049054013a1b77]*/
+/*[clinic end generated code: output=09df354d3374dfb2 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/bytesobject.c.h b/Objects/clinic/bytesobject.c.h
index 69c3506..7e2ce1a 100644
--- a/Objects/clinic/bytesobject.c.h
+++ b/Objects/clinic/bytesobject.c.h
@@ -99,7 +99,7 @@
         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 @@
         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 @@
         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 @@
         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 @@
     }
     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 @@
         }
     }
     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 @@
     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 @@
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=2d0a3733e13e753a input=a9049054013a1b77]*/
+/*[clinic end generated code: output=dbed3c3ff6faa382 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/codeobject.c.h b/Objects/clinic/codeobject.c.h
index ec127ce..6596de0 100644
--- a/Objects/clinic/codeobject.c.h
+++ b/Objects/clinic/codeobject.c.h
@@ -158,7 +158,7 @@
     }
     if (args[7]) {
         if (!PyBytes_Check(args[7])) {
-            _PyArg_BadArgument("replace", 8, "bytes", args[7]);
+            _PyArg_BadArgument("replace", "argument 'co_code'", "bytes", args[7]);
             goto exit;
         }
         co_code = (PyBytesObject *)args[7];
@@ -168,7 +168,7 @@
     }
     if (args[8]) {
         if (!PyTuple_Check(args[8])) {
-            _PyArg_BadArgument("replace", 9, "tuple", args[8]);
+            _PyArg_BadArgument("replace", "argument 'co_consts'", "tuple", args[8]);
             goto exit;
         }
         co_consts = args[8];
@@ -178,7 +178,7 @@
     }
     if (args[9]) {
         if (!PyTuple_Check(args[9])) {
-            _PyArg_BadArgument("replace", 10, "tuple", args[9]);
+            _PyArg_BadArgument("replace", "argument 'co_names'", "tuple", args[9]);
             goto exit;
         }
         co_names = args[9];
@@ -188,7 +188,7 @@
     }
     if (args[10]) {
         if (!PyTuple_Check(args[10])) {
-            _PyArg_BadArgument("replace", 11, "tuple", args[10]);
+            _PyArg_BadArgument("replace", "argument 'co_varnames'", "tuple", args[10]);
             goto exit;
         }
         co_varnames = args[10];
@@ -198,7 +198,7 @@
     }
     if (args[11]) {
         if (!PyTuple_Check(args[11])) {
-            _PyArg_BadArgument("replace", 12, "tuple", args[11]);
+            _PyArg_BadArgument("replace", "argument 'co_freevars'", "tuple", args[11]);
             goto exit;
         }
         co_freevars = args[11];
@@ -208,7 +208,7 @@
     }
     if (args[12]) {
         if (!PyTuple_Check(args[12])) {
-            _PyArg_BadArgument("replace", 13, "tuple", args[12]);
+            _PyArg_BadArgument("replace", "argument 'co_cellvars'", "tuple", args[12]);
             goto exit;
         }
         co_cellvars = args[12];
@@ -218,7 +218,7 @@
     }
     if (args[13]) {
         if (!PyUnicode_Check(args[13])) {
-            _PyArg_BadArgument("replace", 14, "str", args[13]);
+            _PyArg_BadArgument("replace", "argument 'co_filename'", "str", args[13]);
             goto exit;
         }
         if (PyUnicode_READY(args[13]) == -1) {
@@ -231,7 +231,7 @@
     }
     if (args[14]) {
         if (!PyUnicode_Check(args[14])) {
-            _PyArg_BadArgument("replace", 15, "str", args[14]);
+            _PyArg_BadArgument("replace", "argument 'co_name'", "str", args[14]);
             goto exit;
         }
         if (PyUnicode_READY(args[14]) == -1) {
@@ -243,7 +243,7 @@
         }
     }
     if (!PyBytes_Check(args[15])) {
-        _PyArg_BadArgument("replace", 16, "bytes", args[15]);
+        _PyArg_BadArgument("replace", "argument 'co_lnotab'", "bytes", args[15]);
         goto exit;
     }
     co_lnotab = (PyBytesObject *)args[15];
@@ -253,4 +253,4 @@
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=624ab6f2ea8f0ea4 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=fade581d6313a0c2 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/floatobject.c.h b/Objects/clinic/floatobject.c.h
index 4251d63..6515d11 100644
--- a/Objects/clinic/floatobject.c.h
+++ b/Objects/clinic/floatobject.c.h
@@ -235,7 +235,7 @@
     const char *typestr;
 
     if (!PyUnicode_Check(arg)) {
-        _PyArg_BadArgument("__getformat__", 0, "str", arg);
+        _PyArg_BadArgument("__getformat__", "argument", "str", arg);
         goto exit;
     }
     Py_ssize_t typestr_length;
@@ -289,7 +289,7 @@
         goto exit;
     }
     if (!PyUnicode_Check(args[0])) {
-        _PyArg_BadArgument("__set_format__", 1, "str", args[0]);
+        _PyArg_BadArgument("__set_format__", "argument 1", "str", args[0]);
         goto exit;
     }
     Py_ssize_t typestr_length;
@@ -302,7 +302,7 @@
         goto exit;
     }
     if (!PyUnicode_Check(args[1])) {
-        _PyArg_BadArgument("__set_format__", 2, "str", args[1]);
+        _PyArg_BadArgument("__set_format__", "argument 2", "str", args[1]);
         goto exit;
     }
     Py_ssize_t fmt_length;
@@ -339,7 +339,7 @@
     PyObject *format_spec;
 
     if (!PyUnicode_Check(arg)) {
-        _PyArg_BadArgument("__format__", 0, "str", arg);
+        _PyArg_BadArgument("__format__", "argument", "str", arg);
         goto exit;
     }
     if (PyUnicode_READY(arg) == -1) {
@@ -351,4 +351,4 @@
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=c183029d87dd41fa input=a9049054013a1b77]*/
+/*[clinic end generated code: output=cc8098eb73f1a64c input=a9049054013a1b77]*/
diff --git a/Objects/clinic/funcobject.c.h b/Objects/clinic/funcobject.c.h
index 929797b..17fb13f 100644
--- a/Objects/clinic/funcobject.c.h
+++ b/Objects/clinic/funcobject.c.h
@@ -44,12 +44,12 @@
         goto exit;
     }
     if (!PyObject_TypeCheck(fastargs[0], &PyCode_Type)) {
-        _PyArg_BadArgument("function", 1, (&PyCode_Type)->tp_name, fastargs[0]);
+        _PyArg_BadArgument("function", "argument 'code'", (&PyCode_Type)->tp_name, fastargs[0]);
         goto exit;
     }
     code = (PyCodeObject *)fastargs[0];
     if (!PyDict_Check(fastargs[1])) {
-        _PyArg_BadArgument("function", 2, "dict", fastargs[1]);
+        _PyArg_BadArgument("function", "argument 'globals'", "dict", fastargs[1]);
         goto exit;
     }
     globals = fastargs[1];
@@ -75,4 +75,4 @@
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=1d01072cd5620d7e input=a9049054013a1b77]*/
+/*[clinic end generated code: output=3d96afa3396e5c82 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/longobject.c.h b/Objects/clinic/longobject.c.h
index 453edba..27e8dfe 100644
--- a/Objects/clinic/longobject.c.h
+++ b/Objects/clinic/longobject.c.h
@@ -74,7 +74,7 @@
     PyObject *format_spec;
 
     if (!PyUnicode_Check(arg)) {
-        _PyArg_BadArgument("__format__", 0, "str", arg);
+        _PyArg_BadArgument("__format__", "argument", "str", arg);
         goto exit;
     }
     if (PyUnicode_READY(arg) == -1) {
@@ -227,7 +227,7 @@
         length = ival;
     }
     if (!PyUnicode_Check(args[1])) {
-        _PyArg_BadArgument("to_bytes", 2, "str", args[1]);
+        _PyArg_BadArgument("to_bytes", "argument 'byteorder'", "str", args[1]);
         goto exit;
     }
     if (PyUnicode_READY(args[1]) == -1) {
@@ -293,7 +293,7 @@
     }
     bytes_obj = args[0];
     if (!PyUnicode_Check(args[1])) {
-        _PyArg_BadArgument("from_bytes", 2, "str", args[1]);
+        _PyArg_BadArgument("from_bytes", "argument 'byteorder'", "str", args[1]);
         goto exit;
     }
     if (PyUnicode_READY(args[1]) == -1) {
@@ -313,4 +313,4 @@
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=709503897c55bca1 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=77bc3b2615822cb8 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/moduleobject.c.h b/Objects/clinic/moduleobject.c.h
index 512edee..c1534ea 100644
--- a/Objects/clinic/moduleobject.c.h
+++ b/Objects/clinic/moduleobject.c.h
@@ -31,7 +31,7 @@
         goto exit;
     }
     if (!PyUnicode_Check(fastargs[0])) {
-        _PyArg_BadArgument("module", 1, "str", fastargs[0]);
+        _PyArg_BadArgument("module", "argument 'name'", "str", fastargs[0]);
         goto exit;
     }
     if (PyUnicode_READY(fastargs[0]) == -1) {
@@ -48,4 +48,4 @@
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=d7b7ca1237597b08 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=680276bc3a496d7a input=a9049054013a1b77]*/
diff --git a/Objects/clinic/typeobject.c.h b/Objects/clinic/typeobject.c.h
index fbe1261..357eb44 100644
--- a/Objects/clinic/typeobject.c.h
+++ b/Objects/clinic/typeobject.c.h
@@ -200,7 +200,7 @@
     PyObject *format_spec;
 
     if (!PyUnicode_Check(arg)) {
-        _PyArg_BadArgument("__format__", 0, "str", arg);
+        _PyArg_BadArgument("__format__", "argument", "str", arg);
         goto exit;
     }
     if (PyUnicode_READY(arg) == -1) {
@@ -248,4 +248,4 @@
 {
     return object___dir___impl(self);
 }
-/*[clinic end generated code: output=ea5734413064fa7e input=a9049054013a1b77]*/
+/*[clinic end generated code: output=7a6d272d282308f3 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/unicodeobject.c.h b/Objects/clinic/unicodeobject.c.h
index 647507d..cb35087 100644
--- a/Objects/clinic/unicodeobject.c.h
+++ b/Objects/clinic/unicodeobject.c.h
@@ -157,7 +157,7 @@
     }
     if (args[0]) {
         if (!PyUnicode_Check(args[0])) {
-            _PyArg_BadArgument("encode", 1, "str", args[0]);
+            _PyArg_BadArgument("encode", "argument 'encoding'", "str", args[0]);
             goto exit;
         }
         Py_ssize_t encoding_length;
@@ -174,7 +174,7 @@
         }
     }
     if (!PyUnicode_Check(args[1])) {
-        _PyArg_BadArgument("encode", 2, "str", args[1]);
+        _PyArg_BadArgument("encode", "argument 'errors'", "str", args[1]);
         goto exit;
     }
     Py_ssize_t errors_length;
@@ -712,7 +712,7 @@
         goto exit;
     }
     if (!PyUnicode_Check(args[0])) {
-        _PyArg_BadArgument("replace", 1, "str", args[0]);
+        _PyArg_BadArgument("replace", "argument 1", "str", args[0]);
         goto exit;
     }
     if (PyUnicode_READY(args[0]) == -1) {
@@ -720,7 +720,7 @@
     }
     old = args[0];
     if (!PyUnicode_Check(args[1])) {
-        _PyArg_BadArgument("replace", 2, "str", args[1]);
+        _PyArg_BadArgument("replace", "argument 2", "str", args[1]);
         goto exit;
     }
     if (PyUnicode_READY(args[1]) == -1) {
@@ -1080,7 +1080,7 @@
         goto skip_optional;
     }
     if (!PyUnicode_Check(args[1])) {
-        _PyArg_BadArgument("maketrans", 2, "str", args[1]);
+        _PyArg_BadArgument("maketrans", "argument 2", "str", args[1]);
         goto exit;
     }
     if (PyUnicode_READY(args[1]) == -1) {
@@ -1091,7 +1091,7 @@
         goto skip_optional;
     }
     if (!PyUnicode_Check(args[2])) {
-        _PyArg_BadArgument("maketrans", 3, "str", args[2]);
+        _PyArg_BadArgument("maketrans", "argument 3", "str", args[2]);
         goto exit;
     }
     if (PyUnicode_READY(args[2]) == -1) {
@@ -1202,7 +1202,7 @@
     PyObject *format_spec;
 
     if (!PyUnicode_Check(arg)) {
-        _PyArg_BadArgument("__format__", 0, "str", arg);
+        _PyArg_BadArgument("__format__", "argument", "str", arg);
         goto exit;
     }
     if (PyUnicode_READY(arg) == -1) {
@@ -1232,4 +1232,4 @@
 {
     return unicode_sizeof_impl(self);
 }
-/*[clinic end generated code: output=d1541724cb4a0070 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=d9a6ee45ddd0ccfd input=a9049054013a1b77]*/
diff --git a/Objects/stringlib/clinic/transmogrify.h.h b/Objects/stringlib/clinic/transmogrify.h.h
index 0c53a75..8a3a060 100644
--- a/Objects/stringlib/clinic/transmogrify.h.h
+++ b/Objects/stringlib/clinic/transmogrify.h.h
@@ -100,7 +100,7 @@
         fillchar = PyByteArray_AS_STRING(args[1])[0];
     }
     else {
-        _PyArg_BadArgument("ljust", 2, "a byte string of length 1", args[1]);
+        _PyArg_BadArgument("ljust", "argument 2", "a byte string of length 1", args[1]);
         goto exit;
     }
 skip_optional:
@@ -161,7 +161,7 @@
         fillchar = PyByteArray_AS_STRING(args[1])[0];
     }
     else {
-        _PyArg_BadArgument("rjust", 2, "a byte string of length 1", args[1]);
+        _PyArg_BadArgument("rjust", "argument 2", "a byte string of length 1", args[1]);
         goto exit;
     }
 skip_optional:
@@ -222,7 +222,7 @@
         fillchar = PyByteArray_AS_STRING(args[1])[0];
     }
     else {
-        _PyArg_BadArgument("center", 2, "a byte string of length 1", args[1]);
+        _PyArg_BadArgument("center", "argument 2", "a byte string of length 1", args[1]);
         goto exit;
     }
 skip_optional:
@@ -274,4 +274,4 @@
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=96cbb19b238d0e84 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=15be047aef999b4e input=a9049054013a1b77]*/