mirror of
https://github.com/python/cpython.git
synced 2026-01-06 23:42:34 +00:00
bpo-23867: Argument Clinic: inline parsing code for a single positional parameter. (GH-9689)
This commit is contained in:
parent
65ce60aef1
commit
32d96a2b5b
49 changed files with 1677 additions and 275 deletions
21
Objects/clinic/bytesobject.c.h
generated
21
Objects/clinic/bytesobject.c.h
generated
|
|
@ -66,7 +66,11 @@ bytes_partition(PyBytesObject *self, PyObject *arg)
|
|||
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 @@ bytes_rpartition(PyBytesObject *self, PyObject *arg)
|
|||
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 @@ bytes_fromhex(PyTypeObject *type, PyObject *arg)
|
|||
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]*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue