Skip to content

bpo-29464: Rename METH_FASTCALL to METH_FASTCALL|METH_KEYWORDS and make #1955

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Include/methodobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ PyAPI_DATA(PyTypeObject) PyCFunction_Type;
#define PyCFunction_Check(op) (Py_TYPE(op) == &PyCFunction_Type)

typedef PyObject *(*PyCFunction)(PyObject *, PyObject *);
typedef PyObject *(*_PyCFunctionFast) (PyObject *self, PyObject **args,
Py_ssize_t nargs, PyObject *kwnames);
typedef PyObject *(*_PyCFunctionFast) (PyObject *, PyObject **, Py_ssize_t);
typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *,
PyObject *);
typedef PyObject *(*_PyCFunctionFastWithKeywords) (PyObject *,
PyObject **, Py_ssize_t,
PyObject *);
typedef PyObject *(*PyNoArgsFunction)(PyObject *);

PyAPI_FUNC(PyCFunction) PyCFunction_GetFunction(PyObject *);
Expand Down
18 changes: 3 additions & 15 deletions Modules/_collectionsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -912,14 +912,10 @@ _deque_rotate(dequeobject *deque, Py_ssize_t n)
}

static PyObject *
deque_rotate(dequeobject *deque, PyObject **args, Py_ssize_t nargs,
PyObject *kwnames)
deque_rotate(dequeobject *deque, PyObject **args, Py_ssize_t nargs)
{
Py_ssize_t n=1;

if (!_PyArg_NoStackKeywords("rotate", kwnames)) {
return NULL;
}
if (!_PyArg_ParseStack(args, nargs, "|n:rotate", &n)) {
return NULL;
}
Expand Down Expand Up @@ -1052,8 +1048,7 @@ deque_len(dequeobject *deque)
}

static PyObject *
deque_index(dequeobject *deque, PyObject **args, Py_ssize_t nargs,
PyObject *kwnames)
deque_index(dequeobject *deque, PyObject **args, Py_ssize_t nargs)
{
Py_ssize_t i, n, start=0, stop=Py_SIZE(deque);
PyObject *v, *item;
Expand All @@ -1062,9 +1057,6 @@ deque_index(dequeobject *deque, PyObject **args, Py_ssize_t nargs,
size_t start_state = deque->state;
int cmp;

if (!_PyArg_NoStackKeywords("index", kwnames)) {
return NULL;
}
if (!_PyArg_ParseStack(args, nargs, "O|O&O&:index", &v,
_PyEval_SliceIndexNotNone, &start,
_PyEval_SliceIndexNotNone, &stop)) {
Expand Down Expand Up @@ -1133,17 +1125,13 @@ PyDoc_STRVAR(index_doc,
*/

static PyObject *
deque_insert(dequeobject *deque, PyObject **args, Py_ssize_t nargs,
PyObject *kwnames)
deque_insert(dequeobject *deque, PyObject **args, Py_ssize_t nargs)
{
Py_ssize_t index;
Py_ssize_t n = Py_SIZE(deque);
PyObject *value;
PyObject *rv;

if (!_PyArg_NoStackKeywords("insert", kwnames)) {
return NULL;
}
if (!_PyArg_ParseStack(args, nargs, "nO:insert", &index, &value)) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion Modules/_elementtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -2774,7 +2774,7 @@ typedef struct {
} XMLParserObject;

static PyObject*
_elementtree_XMLParser_doctype(XMLParserObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames);
_elementtree_XMLParser_doctype(XMLParserObject *self, PyObject **args, Py_ssize_t nargs);
static PyObject *
_elementtree_XMLParser_doctype_impl(XMLParserObject *self, PyObject *name,
PyObject *pubid, PyObject *system);
Expand Down
2 changes: 1 addition & 1 deletion Modules/_hashopenssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ generate_hash_name_list(void)

/* a PyMethodDef structure for the constructor */
#define CONSTRUCTOR_METH_DEF(NAME) \
{"openssl_" #NAME, (PyCFunction)EVP_new_ ## NAME, METH_FASTCALL, \
{"openssl_" #NAME, (PyCFunction)EVP_new_ ## NAME, METH_FASTCALL | METH_KEYWORDS, \
PyDoc_STR("Returns a " #NAME \
" hash object; optionally initialized with a string") \
}
Expand Down
4 changes: 2 additions & 2 deletions Modules/_io/clinic/_iomodule.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ PyDoc_STRVAR(_io_open__doc__,
"opened in a binary mode.");

#define _IO_OPEN_METHODDEF \
{"open", (PyCFunction)_io_open, METH_FASTCALL, _io_open__doc__},
{"open", (PyCFunction)_io_open, METH_FASTCALL|METH_KEYWORDS, _io_open__doc__},

static PyObject *
_io_open_impl(PyObject *module, PyObject *file, const char *mode,
Expand Down Expand Up @@ -158,4 +158,4 @@ _io_open(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
exit:
return return_value;
}
/*[clinic end generated code: output=e6011c784fe6589b input=a9049054013a1b77]*/
/*[clinic end generated code: output=7e0ab289d8465580 input=a9049054013a1b77]*/
38 changes: 7 additions & 31 deletions Modules/_io/clinic/bufferedio.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,11 @@ static PyObject *
_io__Buffered_peek_impl(buffered *self, Py_ssize_t size);

static PyObject *
_io__Buffered_peek(buffered *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
_io__Buffered_peek(buffered *self, PyObject **args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
Py_ssize_t size = 0;

if (!_PyArg_NoStackKeywords("peek", kwnames)) {
goto exit;
}

if (!_PyArg_ParseStack(args, nargs, "|n:peek",
&size)) {
goto exit;
Expand All @@ -128,15 +124,11 @@ static PyObject *
_io__Buffered_read_impl(buffered *self, Py_ssize_t n);

static PyObject *
_io__Buffered_read(buffered *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
_io__Buffered_read(buffered *self, PyObject **args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
Py_ssize_t n = -1;

if (!_PyArg_NoStackKeywords("read", kwnames)) {
goto exit;
}

if (!_PyArg_ParseStack(args, nargs, "|O&:read",
_Py_convert_optional_to_ssize_t, &n)) {
goto exit;
Expand All @@ -159,15 +151,11 @@ static PyObject *
_io__Buffered_read1_impl(buffered *self, Py_ssize_t n);

static PyObject *
_io__Buffered_read1(buffered *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
_io__Buffered_read1(buffered *self, PyObject **args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
Py_ssize_t n = -1;

if (!_PyArg_NoStackKeywords("read1", kwnames)) {
goto exit;
}

if (!_PyArg_ParseStack(args, nargs, "|n:read1",
&n)) {
goto exit;
Expand Down Expand Up @@ -252,15 +240,11 @@ static PyObject *
_io__Buffered_readline_impl(buffered *self, Py_ssize_t size);

static PyObject *
_io__Buffered_readline(buffered *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
_io__Buffered_readline(buffered *self, PyObject **args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
Py_ssize_t size = -1;

if (!_PyArg_NoStackKeywords("readline", kwnames)) {
goto exit;
}

if (!_PyArg_ParseStack(args, nargs, "|O&:readline",
_Py_convert_optional_to_ssize_t, &size)) {
goto exit;
Expand All @@ -283,16 +267,12 @@ static PyObject *
_io__Buffered_seek_impl(buffered *self, PyObject *targetobj, int whence);

static PyObject *
_io__Buffered_seek(buffered *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
_io__Buffered_seek(buffered *self, PyObject **args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
PyObject *targetobj;
int whence = 0;

if (!_PyArg_NoStackKeywords("seek", kwnames)) {
goto exit;
}

if (!_PyArg_ParseStack(args, nargs, "O|i:seek",
&targetobj, &whence)) {
goto exit;
Expand All @@ -315,15 +295,11 @@ static PyObject *
_io__Buffered_truncate_impl(buffered *self, PyObject *pos);

static PyObject *
_io__Buffered_truncate(buffered *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
_io__Buffered_truncate(buffered *self, PyObject **args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
PyObject *pos = Py_None;

if (!_PyArg_NoStackKeywords("truncate", kwnames)) {
goto exit;
}

if (!_PyArg_UnpackStack(args, nargs, "truncate",
0, 1,
&pos)) {
Expand Down Expand Up @@ -500,4 +476,4 @@ _io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs)
exit:
return return_value;
}
/*[clinic end generated code: output=4f7490f82427c63b input=a9049054013a1b77]*/
/*[clinic end generated code: output=2b817df0bf814ddc input=a9049054013a1b77]*/
38 changes: 7 additions & 31 deletions Modules/_io/clinic/bytesio.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,11 @@ static PyObject *
_io_BytesIO_read_impl(bytesio *self, Py_ssize_t size);

static PyObject *
_io_BytesIO_read(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
_io_BytesIO_read(bytesio *self, PyObject **args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
Py_ssize_t size = -1;

if (!_PyArg_NoStackKeywords("read", kwnames)) {
goto exit;
}

if (!_PyArg_ParseStack(args, nargs, "|O&:read",
_Py_convert_optional_to_ssize_t, &size)) {
goto exit;
Expand All @@ -199,15 +195,11 @@ static PyObject *
_io_BytesIO_read1_impl(bytesio *self, Py_ssize_t size);

static PyObject *
_io_BytesIO_read1(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
_io_BytesIO_read1(bytesio *self, PyObject **args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
Py_ssize_t size = -1;

if (!_PyArg_NoStackKeywords("read1", kwnames)) {
goto exit;
}

if (!_PyArg_ParseStack(args, nargs, "|O&:read1",
_Py_convert_optional_to_ssize_t, &size)) {
goto exit;
Expand Down Expand Up @@ -235,15 +227,11 @@ static PyObject *
_io_BytesIO_readline_impl(bytesio *self, Py_ssize_t size);

static PyObject *
_io_BytesIO_readline(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
_io_BytesIO_readline(bytesio *self, PyObject **args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
Py_ssize_t size = -1;

if (!_PyArg_NoStackKeywords("readline", kwnames)) {
goto exit;
}

if (!_PyArg_ParseStack(args, nargs, "|O&:readline",
_Py_convert_optional_to_ssize_t, &size)) {
goto exit;
Expand Down Expand Up @@ -271,15 +259,11 @@ static PyObject *
_io_BytesIO_readlines_impl(bytesio *self, PyObject *arg);

static PyObject *
_io_BytesIO_readlines(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
_io_BytesIO_readlines(bytesio *self, PyObject **args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
PyObject *arg = Py_None;

if (!_PyArg_NoStackKeywords("readlines", kwnames)) {
goto exit;
}

if (!_PyArg_UnpackStack(args, nargs, "readlines",
0, 1,
&arg)) {
Expand Down Expand Up @@ -342,15 +326,11 @@ static PyObject *
_io_BytesIO_truncate_impl(bytesio *self, Py_ssize_t size);

static PyObject *
_io_BytesIO_truncate(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
_io_BytesIO_truncate(bytesio *self, PyObject **args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
Py_ssize_t size = self->pos;

if (!_PyArg_NoStackKeywords("truncate", kwnames)) {
goto exit;
}

if (!_PyArg_ParseStack(args, nargs, "|O&:truncate",
_Py_convert_optional_to_ssize_t, &size)) {
goto exit;
Expand Down Expand Up @@ -380,16 +360,12 @@ static PyObject *
_io_BytesIO_seek_impl(bytesio *self, Py_ssize_t pos, int whence);

static PyObject *
_io_BytesIO_seek(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
_io_BytesIO_seek(bytesio *self, PyObject **args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
Py_ssize_t pos;
int whence = 0;

if (!_PyArg_NoStackKeywords("seek", kwnames)) {
goto exit;
}

if (!_PyArg_ParseStack(args, nargs, "n|i:seek",
&pos, &whence)) {
goto exit;
Expand Down Expand Up @@ -468,4 +444,4 @@ _io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
exit:
return return_value;
}
/*[clinic end generated code: output=9e63715414bffb2a input=a9049054013a1b77]*/
/*[clinic end generated code: output=20946f5a2ed4492b input=a9049054013a1b77]*/
20 changes: 4 additions & 16 deletions Modules/_io/clinic/fileio.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,11 @@ static PyObject *
_io_FileIO_read_impl(fileio *self, Py_ssize_t size);

static PyObject *
_io_FileIO_read(fileio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
_io_FileIO_read(fileio *self, PyObject **args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
Py_ssize_t size = -1;

if (!_PyArg_NoStackKeywords("read", kwnames)) {
goto exit;
}

if (!_PyArg_ParseStack(args, nargs, "|O&:read",
_Py_convert_optional_to_ssize_t, &size)) {
goto exit;
Expand Down Expand Up @@ -284,16 +280,12 @@ static PyObject *
_io_FileIO_seek_impl(fileio *self, PyObject *pos, int whence);

static PyObject *
_io_FileIO_seek(fileio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
_io_FileIO_seek(fileio *self, PyObject **args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
PyObject *pos;
int whence = 0;

if (!_PyArg_NoStackKeywords("seek", kwnames)) {
goto exit;
}

if (!_PyArg_ParseStack(args, nargs, "O|i:seek",
&pos, &whence)) {
goto exit;
Expand Down Expand Up @@ -342,15 +334,11 @@ static PyObject *
_io_FileIO_truncate_impl(fileio *self, PyObject *posobj);

static PyObject *
_io_FileIO_truncate(fileio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
_io_FileIO_truncate(fileio *self, PyObject **args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
PyObject *posobj = NULL;

if (!_PyArg_NoStackKeywords("truncate", kwnames)) {
goto exit;
}

if (!_PyArg_UnpackStack(args, nargs, "truncate",
0, 1,
&posobj)) {
Expand Down Expand Up @@ -385,4 +373,4 @@ _io_FileIO_isatty(fileio *self, PyObject *Py_UNUSED(ignored))
#ifndef _IO_FILEIO_TRUNCATE_METHODDEF
#define _IO_FILEIO_TRUNCATE_METHODDEF
#endif /* !defined(_IO_FILEIO_TRUNCATE_METHODDEF) */
/*[clinic end generated code: output=2c6a5470100a8f10 input=a9049054013a1b77]*/
/*[clinic end generated code: output=1af8b4031633b763 input=a9049054013a1b77]*/
Loading