bpo-23867: Argument Clinic: inline parsing code for a single positional parameter. (GH-9689)

diff --git a/Objects/clinic/bytearrayobject.c.h b/Objects/clinic/bytearrayobject.c.h
index f21353a..ec35eef 100644
--- a/Objects/clinic/bytearrayobject.c.h
+++ b/Objects/clinic/bytearrayobject.c.h
@@ -354,7 +354,7 @@
     PyObject *return_value = NULL;
     int item;
 
-    if (!PyArg_Parse(arg, "O&:append", _getbytevalue, &item)) {
+    if (!_getbytevalue(arg, &item)) {
         goto exit;
     }
     return_value = bytearray_append_impl(self, item);
@@ -430,7 +430,7 @@
     PyObject *return_value = NULL;
     int value;
 
-    if (!PyArg_Parse(arg, "O&:remove", _getbytevalue, &value)) {
+    if (!_getbytevalue(arg, &value)) {
         goto exit;
     }
     return_value = bytearray_remove_impl(self, value);
@@ -640,9 +640,14 @@
     PyObject *return_value = NULL;
     PyObject *string;
 
-    if (!PyArg_Parse(arg, "U:fromhex", &string)) {
+    if (!PyUnicode_Check(arg)) {
+        _PyArg_BadArgument("fromhex", "str", arg);
         goto exit;
     }
+    if (PyUnicode_READY(arg) == -1) {
+        goto exit;
+    }
+    string = arg;
     return_value = bytearray_fromhex_impl(type, string);
 
 exit:
@@ -712,4 +717,4 @@
 {
     return bytearray_sizeof_impl(self);
 }
-/*[clinic end generated code: output=b88bb192dddca6e1 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=cd3e13a1905a473c input=a9049054013a1b77]*/
diff --git a/Objects/clinic/bytesobject.c.h b/Objects/clinic/bytesobject.c.h
index 193d534..1345b64 100644
--- a/Objects/clinic/bytesobject.c.h
+++ b/Objects/clinic/bytesobject.c.h
@@ -66,7 +66,11 @@
     PyObject *return_value = NULL;
     Py_buffer sep = {NULL, NULL};
 
-    if (!PyArg_Parse(arg, "y*:partition", &sep)) {
+    if (PyObject_GetBuffer(arg, &sep, PyBUF_SIMPLE) != 0) {
+        goto exit;
+    }
+    if (!PyBuffer_IsContiguous(&sep, 'C')) {
+        _PyArg_BadArgument("partition", "contiguous buffer", arg);
         goto exit;
     }
     return_value = bytes_partition_impl(self, &sep);
@@ -105,7 +109,11 @@
     PyObject *return_value = NULL;
     Py_buffer sep = {NULL, NULL};
 
-    if (!PyArg_Parse(arg, "y*:rpartition", &sep)) {
+    if (PyObject_GetBuffer(arg, &sep, PyBUF_SIMPLE) != 0) {
+        goto exit;
+    }
+    if (!PyBuffer_IsContiguous(&sep, 'C')) {
+        _PyArg_BadArgument("rpartition", "contiguous buffer", arg);
         goto exit;
     }
     return_value = bytes_rpartition_impl(self, &sep);
@@ -491,12 +499,17 @@
     PyObject *return_value = NULL;
     PyObject *string;
 
-    if (!PyArg_Parse(arg, "U:fromhex", &string)) {
+    if (!PyUnicode_Check(arg)) {
+        _PyArg_BadArgument("fromhex", "str", arg);
         goto exit;
     }
+    if (PyUnicode_READY(arg) == -1) {
+        goto exit;
+    }
+    string = arg;
     return_value = bytes_fromhex_impl(type, string);
 
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=07b33ac65362301b input=a9049054013a1b77]*/
+/*[clinic end generated code: output=dc9aa04f0007ab11 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/floatobject.c.h b/Objects/clinic/floatobject.c.h
index 8ff2a2b..28b24d0 100644
--- a/Objects/clinic/floatobject.c.h
+++ b/Objects/clinic/floatobject.c.h
@@ -228,7 +228,17 @@
     PyObject *return_value = NULL;
     const char *typestr;
 
-    if (!PyArg_Parse(arg, "s:__getformat__", &typestr)) {
+    if (!PyUnicode_Check(arg)) {
+        _PyArg_BadArgument("__getformat__", "str", arg);
+        goto exit;
+    }
+    Py_ssize_t typestr_length;
+    typestr = PyUnicode_AsUTF8AndSize(arg, &typestr_length);
+    if (typestr == NULL) {
+        goto exit;
+    }
+    if (strlen(typestr) != (size_t)typestr_length) {
+        PyErr_SetString(PyExc_ValueError, "embedded null character");
         goto exit;
     }
     return_value = float___getformat___impl(type, typestr);
@@ -297,12 +307,17 @@
     PyObject *return_value = NULL;
     PyObject *format_spec;
 
-    if (!PyArg_Parse(arg, "U:__format__", &format_spec)) {
+    if (!PyUnicode_Check(arg)) {
+        _PyArg_BadArgument("__format__", "str", arg);
         goto exit;
     }
+    if (PyUnicode_READY(arg) == -1) {
+        goto exit;
+    }
+    format_spec = arg;
     return_value = float___format___impl(self, format_spec);
 
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=091dd499f5386a6c input=a9049054013a1b77]*/
+/*[clinic end generated code: output=e8f8be828462d58b input=a9049054013a1b77]*/
diff --git a/Objects/clinic/longobject.c.h b/Objects/clinic/longobject.c.h
index 3c33993..27cdf9e 100644
--- a/Objects/clinic/longobject.c.h
+++ b/Objects/clinic/longobject.c.h
@@ -58,9 +58,14 @@
     PyObject *return_value = NULL;
     PyObject *format_spec;
 
-    if (!PyArg_Parse(arg, "U:__format__", &format_spec)) {
+    if (!PyUnicode_Check(arg)) {
+        _PyArg_BadArgument("__format__", "str", arg);
         goto exit;
     }
+    if (PyUnicode_READY(arg) == -1) {
+        goto exit;
+    }
+    format_spec = arg;
     return_value = int___format___impl(self, format_spec);
 
 exit:
@@ -239,4 +244,4 @@
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=403ccd096555fd1e input=a9049054013a1b77]*/
+/*[clinic end generated code: output=7436b5f4decdcf9d input=a9049054013a1b77]*/
diff --git a/Objects/clinic/typeobject.c.h b/Objects/clinic/typeobject.c.h
index 2760065..115a218 100644
--- a/Objects/clinic/typeobject.c.h
+++ b/Objects/clinic/typeobject.c.h
@@ -166,7 +166,13 @@
     PyObject *return_value = NULL;
     int protocol;
 
-    if (!PyArg_Parse(arg, "i:__reduce_ex__", &protocol)) {
+    if (PyFloat_Check(arg)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "integer argument expected, got float" );
+        goto exit;
+    }
+    protocol = _PyLong_AsInt(arg);
+    if (protocol == -1 && PyErr_Occurred()) {
         goto exit;
     }
     return_value = object___reduce_ex___impl(self, protocol);
@@ -193,9 +199,14 @@
     PyObject *return_value = NULL;
     PyObject *format_spec;
 
-    if (!PyArg_Parse(arg, "U:__format__", &format_spec)) {
+    if (!PyUnicode_Check(arg)) {
+        _PyArg_BadArgument("__format__", "str", arg);
         goto exit;
     }
+    if (PyUnicode_READY(arg) == -1) {
+        goto exit;
+    }
+    format_spec = arg;
     return_value = object___format___impl(self, format_spec);
 
 exit:
@@ -237,4 +248,4 @@
 {
     return object___dir___impl(self);
 }
-/*[clinic end generated code: output=8c4c856859564eaa input=a9049054013a1b77]*/
+/*[clinic end generated code: output=09f3453839e60136 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/unicodeobject.c.h b/Objects/clinic/unicodeobject.c.h
index 273ae92..744a6eb 100644
--- a/Objects/clinic/unicodeobject.c.h
+++ b/Objects/clinic/unicodeobject.c.h
@@ -898,9 +898,23 @@
     PyObject *return_value = NULL;
     Py_ssize_t width;
 
-    if (!PyArg_Parse(arg, "n:zfill", &width)) {
+    if (PyFloat_Check(arg)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "integer argument expected, got float" );
         goto exit;
     }
+    {
+        Py_ssize_t ival = -1;
+        PyObject *iobj = PyNumber_Index(arg);
+        if (iobj != NULL) {
+            ival = PyLong_AsSsize_t(iobj);
+            Py_DECREF(iobj);
+        }
+        if (ival == -1 && PyErr_Occurred()) {
+            goto exit;
+        }
+        width = ival;
+    }
     return_value = unicode_zfill_impl(self, width);
 
 exit:
@@ -925,9 +939,14 @@
     PyObject *return_value = NULL;
     PyObject *format_spec;
 
-    if (!PyArg_Parse(arg, "U:__format__", &format_spec)) {
+    if (!PyUnicode_Check(arg)) {
+        _PyArg_BadArgument("__format__", "str", arg);
         goto exit;
     }
+    if (PyUnicode_READY(arg) == -1) {
+        goto exit;
+    }
+    format_spec = arg;
     return_value = unicode___format___impl(self, format_spec);
 
 exit:
@@ -951,4 +970,4 @@
 {
     return unicode_sizeof_impl(self);
 }
-/*[clinic end generated code: output=d323802b67bfc6d8 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ff6acd5abd1998eb input=a9049054013a1b77]*/
diff --git a/Objects/stringlib/clinic/transmogrify.h.h b/Objects/stringlib/clinic/transmogrify.h.h
index fb63060..7b7fd58 100644
--- a/Objects/stringlib/clinic/transmogrify.h.h
+++ b/Objects/stringlib/clinic/transmogrify.h.h
@@ -147,12 +147,26 @@
     PyObject *return_value = NULL;
     Py_ssize_t width;
 
-    if (!PyArg_Parse(arg, "n:zfill", &width)) {
+    if (PyFloat_Check(arg)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "integer argument expected, got float" );
         goto exit;
     }
+    {
+        Py_ssize_t ival = -1;
+        PyObject *iobj = PyNumber_Index(arg);
+        if (iobj != NULL) {
+            ival = PyLong_AsSsize_t(iobj);
+            Py_DECREF(iobj);
+        }
+        if (ival == -1 && PyErr_Occurred()) {
+            goto exit;
+        }
+        width = ival;
+    }
     return_value = stringlib_zfill_impl(self, width);
 
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=d09ba158d470566e input=a9049054013a1b77]*/
+/*[clinic end generated code: output=bf2ef501639e1190 input=a9049054013a1b77]*/