mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +00:00
Issue #23492: Argument Clinic now generates argument parsing code with
PyArg_Parse instead of PyArg_ParseTuple if possible.
This commit is contained in:
parent
1009bf18b3
commit
92e8af67a8
17 changed files with 320 additions and 302 deletions
|
@ -339,18 +339,18 @@ PyDoc_STRVAR(bytearray_append__doc__,
|
|||
" The item to be appended.");
|
||||
|
||||
#define BYTEARRAY_APPEND_METHODDEF \
|
||||
{"append", (PyCFunction)bytearray_append, METH_VARARGS, bytearray_append__doc__},
|
||||
{"append", (PyCFunction)bytearray_append, METH_O, bytearray_append__doc__},
|
||||
|
||||
static PyObject *
|
||||
bytearray_append_impl(PyByteArrayObject *self, int item);
|
||||
|
||||
static PyObject *
|
||||
bytearray_append(PyByteArrayObject *self, PyObject *args)
|
||||
bytearray_append(PyByteArrayObject *self, PyObject *arg)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
int item;
|
||||
|
||||
if (!PyArg_ParseTuple(args,
|
||||
if (!PyArg_Parse(arg,
|
||||
"O&:append",
|
||||
_getbytevalue, &item))
|
||||
goto exit;
|
||||
|
@ -416,18 +416,18 @@ PyDoc_STRVAR(bytearray_remove__doc__,
|
|||
" The value to remove.");
|
||||
|
||||
#define BYTEARRAY_REMOVE_METHODDEF \
|
||||
{"remove", (PyCFunction)bytearray_remove, METH_VARARGS, bytearray_remove__doc__},
|
||||
{"remove", (PyCFunction)bytearray_remove, METH_O, bytearray_remove__doc__},
|
||||
|
||||
static PyObject *
|
||||
bytearray_remove_impl(PyByteArrayObject *self, int value);
|
||||
|
||||
static PyObject *
|
||||
bytearray_remove(PyByteArrayObject *self, PyObject *args)
|
||||
bytearray_remove(PyByteArrayObject *self, PyObject *arg)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
int value;
|
||||
|
||||
if (!PyArg_ParseTuple(args,
|
||||
if (!PyArg_Parse(arg,
|
||||
"O&:remove",
|
||||
_getbytevalue, &value))
|
||||
goto exit;
|
||||
|
@ -621,18 +621,18 @@ PyDoc_STRVAR(bytearray_fromhex__doc__,
|
|||
"Example: bytearray.fromhex(\'B9 01EF\') -> bytearray(b\'\\\\xb9\\\\x01\\\\xef\')");
|
||||
|
||||
#define BYTEARRAY_FROMHEX_METHODDEF \
|
||||
{"fromhex", (PyCFunction)bytearray_fromhex, METH_VARARGS|METH_CLASS, bytearray_fromhex__doc__},
|
||||
{"fromhex", (PyCFunction)bytearray_fromhex, METH_O|METH_CLASS, bytearray_fromhex__doc__},
|
||||
|
||||
static PyObject *
|
||||
bytearray_fromhex_impl(PyObject*cls, PyObject *string);
|
||||
|
||||
static PyObject *
|
||||
bytearray_fromhex(PyTypeObject *cls, PyObject *args)
|
||||
bytearray_fromhex(PyTypeObject *cls, PyObject *arg)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *string;
|
||||
|
||||
if (!PyArg_ParseTuple(args,
|
||||
if (!PyArg_Parse(arg,
|
||||
"U:fromhex",
|
||||
&string))
|
||||
goto exit;
|
||||
|
@ -705,4 +705,4 @@ bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
|
|||
{
|
||||
return bytearray_sizeof_impl(self);
|
||||
}
|
||||
/*[clinic end generated code: output=70ea384faeca8d16 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=d763876718a66fc3 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -54,18 +54,18 @@ PyDoc_STRVAR(bytes_partition__doc__,
|
|||
"object and two empty bytes objects.");
|
||||
|
||||
#define BYTES_PARTITION_METHODDEF \
|
||||
{"partition", (PyCFunction)bytes_partition, METH_VARARGS, bytes_partition__doc__},
|
||||
{"partition", (PyCFunction)bytes_partition, METH_O, bytes_partition__doc__},
|
||||
|
||||
static PyObject *
|
||||
bytes_partition_impl(PyBytesObject *self, Py_buffer *sep);
|
||||
|
||||
static PyObject *
|
||||
bytes_partition(PyBytesObject *self, PyObject *args)
|
||||
bytes_partition(PyBytesObject *self, PyObject *arg)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_buffer sep = {NULL, NULL};
|
||||
|
||||
if (!PyArg_ParseTuple(args,
|
||||
if (!PyArg_Parse(arg,
|
||||
"y*:partition",
|
||||
&sep))
|
||||
goto exit;
|
||||
|
@ -93,18 +93,18 @@ PyDoc_STRVAR(bytes_rpartition__doc__,
|
|||
"objects and the original bytes object.");
|
||||
|
||||
#define BYTES_RPARTITION_METHODDEF \
|
||||
{"rpartition", (PyCFunction)bytes_rpartition, METH_VARARGS, bytes_rpartition__doc__},
|
||||
{"rpartition", (PyCFunction)bytes_rpartition, METH_O, bytes_rpartition__doc__},
|
||||
|
||||
static PyObject *
|
||||
bytes_rpartition_impl(PyBytesObject *self, Py_buffer *sep);
|
||||
|
||||
static PyObject *
|
||||
bytes_rpartition(PyBytesObject *self, PyObject *args)
|
||||
bytes_rpartition(PyBytesObject *self, PyObject *arg)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_buffer sep = {NULL, NULL};
|
||||
|
||||
if (!PyArg_ParseTuple(args,
|
||||
if (!PyArg_Parse(arg,
|
||||
"y*:rpartition",
|
||||
&sep))
|
||||
goto exit;
|
||||
|
@ -473,18 +473,18 @@ PyDoc_STRVAR(bytes_fromhex__doc__,
|
|||
"Example: bytes.fromhex(\'B9 01EF\') -> b\'\\\\xb9\\\\x01\\\\xef\'.");
|
||||
|
||||
#define BYTES_FROMHEX_METHODDEF \
|
||||
{"fromhex", (PyCFunction)bytes_fromhex, METH_VARARGS|METH_CLASS, bytes_fromhex__doc__},
|
||||
{"fromhex", (PyCFunction)bytes_fromhex, METH_O|METH_CLASS, bytes_fromhex__doc__},
|
||||
|
||||
static PyObject *
|
||||
bytes_fromhex_impl(PyTypeObject *type, PyObject *string);
|
||||
|
||||
static PyObject *
|
||||
bytes_fromhex(PyTypeObject *type, PyObject *args)
|
||||
bytes_fromhex(PyTypeObject *type, PyObject *arg)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *string;
|
||||
|
||||
if (!PyArg_ParseTuple(args,
|
||||
if (!PyArg_Parse(arg,
|
||||
"U:fromhex",
|
||||
&string))
|
||||
goto exit;
|
||||
|
@ -493,4 +493,4 @@ bytes_fromhex(PyTypeObject *type, PyObject *args)
|
|||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=dfe5c9a317b99f49 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=b9e69e1f7c8ccd14 input=a9049054013a1b77]*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue