Backport METH_FASTCALL from Python 3.7 (#328)

This commit is contained in:
Gautham 2022-05-12 14:57:16 +05:30 committed by GitHub
parent 70c97f598b
commit cf73bbd678
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
102 changed files with 2896 additions and 3301 deletions

View file

@ -52,7 +52,7 @@ PyDoc_STRVAR(bytearray_translate__doc__,
"The remaining characters are mapped through the given translation table.");
#define BYTEARRAY_TRANSLATE_METHODDEF \
{"translate", (PyCFunction)bytearray_translate, METH_FASTCALL, bytearray_translate__doc__},
{"translate", (PyCFunction)bytearray_translate, METH_FASTCALL|METH_KEYWORDS, bytearray_translate__doc__},
static PyObject *
bytearray_translate_impl(PyByteArrayObject *self, PyObject *table,
@ -95,7 +95,7 @@ static PyObject *
bytearray_maketrans_impl(Py_buffer *frm, Py_buffer *to);
static PyObject *
bytearray_maketrans(void *null, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
bytearray_maketrans(void *null, PyObject **args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
Py_buffer frm = {NULL, NULL};
@ -105,10 +105,6 @@ bytearray_maketrans(void *null, PyObject **args, Py_ssize_t nargs, PyObject *kwn
&frm, &to)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("maketrans", kwnames)) {
goto exit;
}
return_value = bytearray_maketrans_impl(&frm, &to);
exit:
@ -145,7 +141,7 @@ bytearray_replace_impl(PyByteArrayObject *self, Py_buffer *old,
Py_buffer *new, Py_ssize_t count);
static PyObject *
bytearray_replace(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
bytearray_replace(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
Py_buffer old = {NULL, NULL};
@ -156,10 +152,6 @@ bytearray_replace(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, Py
&old, &new, &count)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("replace", kwnames)) {
goto exit;
}
return_value = bytearray_replace_impl(self, &old, &new, count);
exit:
@ -190,7 +182,7 @@ PyDoc_STRVAR(bytearray_split__doc__,
" -1 (the default value) means no limit.");
#define BYTEARRAY_SPLIT_METHODDEF \
{"split", (PyCFunction)bytearray_split, METH_FASTCALL, bytearray_split__doc__},
{"split", (PyCFunction)bytearray_split, METH_FASTCALL|METH_KEYWORDS, bytearray_split__doc__},
static PyObject *
bytearray_split_impl(PyByteArrayObject *self, PyObject *sep,
@ -265,7 +257,7 @@ PyDoc_STRVAR(bytearray_rsplit__doc__,
"Splitting is done starting at the end of the bytearray and working to the front.");
#define BYTEARRAY_RSPLIT_METHODDEF \
{"rsplit", (PyCFunction)bytearray_rsplit, METH_FASTCALL, bytearray_rsplit__doc__},
{"rsplit", (PyCFunction)bytearray_rsplit, METH_FASTCALL|METH_KEYWORDS, bytearray_rsplit__doc__},
static PyObject *
bytearray_rsplit_impl(PyByteArrayObject *self, PyObject *sep,
@ -326,7 +318,7 @@ static PyObject *
bytearray_insert_impl(PyByteArrayObject *self, Py_ssize_t index, int item);
static PyObject *
bytearray_insert(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
bytearray_insert(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
Py_ssize_t index;
@ -336,10 +328,6 @@ bytearray_insert(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyO
&index, _getbytevalue, &item)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("insert", kwnames)) {
goto exit;
}
return_value = bytearray_insert_impl(self, index, item);
exit:
@ -407,7 +395,7 @@ static PyObject *
bytearray_pop_impl(PyByteArrayObject *self, Py_ssize_t index);
static PyObject *
bytearray_pop(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
bytearray_pop(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
Py_ssize_t index = -1;
@ -416,10 +404,6 @@ bytearray_pop(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyObje
&index)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("pop", kwnames)) {
goto exit;
}
return_value = bytearray_pop_impl(self, index);
exit:
@ -471,7 +455,7 @@ static PyObject *
bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes);
static PyObject *
bytearray_strip(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
bytearray_strip(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
PyObject *bytes = Py_None;
@ -481,10 +465,6 @@ bytearray_strip(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyOb
&bytes)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("strip", kwnames)) {
goto exit;
}
return_value = bytearray_strip_impl(self, bytes);
exit:
@ -506,7 +486,7 @@ static PyObject *
bytearray_lstrip_impl(PyByteArrayObject *self, PyObject *bytes);
static PyObject *
bytearray_lstrip(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
bytearray_lstrip(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
PyObject *bytes = Py_None;
@ -516,10 +496,6 @@ bytearray_lstrip(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyO
&bytes)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("lstrip", kwnames)) {
goto exit;
}
return_value = bytearray_lstrip_impl(self, bytes);
exit:
@ -541,7 +517,7 @@ static PyObject *
bytearray_rstrip_impl(PyByteArrayObject *self, PyObject *bytes);
static PyObject *
bytearray_rstrip(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
bytearray_rstrip(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
PyObject *bytes = Py_None;
@ -551,10 +527,6 @@ bytearray_rstrip(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyO
&bytes)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("rstrip", kwnames)) {
goto exit;
}
return_value = bytearray_rstrip_impl(self, bytes);
exit:
@ -577,7 +549,7 @@ PyDoc_STRVAR(bytearray_decode__doc__,
" can handle UnicodeDecodeErrors.");
#define BYTEARRAY_DECODE_METHODDEF \
{"decode", (PyCFunction)bytearray_decode, METH_FASTCALL, bytearray_decode__doc__},
{"decode", (PyCFunction)bytearray_decode, METH_FASTCALL|METH_KEYWORDS, bytearray_decode__doc__},
static PyObject *
bytearray_decode_impl(PyByteArrayObject *self, const char *encoding,
@ -625,7 +597,7 @@ PyDoc_STRVAR(bytearray_splitlines__doc__,
"true.");
#define BYTEARRAY_SPLITLINES_METHODDEF \
{"splitlines", (PyCFunction)bytearray_splitlines, METH_FASTCALL, bytearray_splitlines__doc__},
{"splitlines", (PyCFunction)bytearray_splitlines, METH_FASTCALL|METH_KEYWORDS, bytearray_splitlines__doc__},
static PyObject *
bytearray_splitlines_impl(PyByteArrayObject *self, int keepends);
@ -709,7 +681,7 @@ static PyObject *
bytearray_reduce_ex_impl(PyByteArrayObject *self, int proto);
static PyObject *
bytearray_reduce_ex(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
bytearray_reduce_ex(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
int proto = 0;
@ -718,10 +690,6 @@ bytearray_reduce_ex(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs,
&proto)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("__reduce_ex__", kwnames)) {
goto exit;
}
return_value = bytearray_reduce_ex_impl(self, proto);
exit:
@ -745,4 +713,4 @@ bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
{
return bytearray_sizeof_impl(self);
}
/*[clinic end generated code: output=c1b1b83b0e19df74 input=a9049054013a1b77]*/
/*[clinic end generated code: output=c2804d009182328c input=a9049054013a1b77]*/