bpo-23867: Argument Clinic: inline parsing code for a single positional parameter. (GH-9689)
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]*/