Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f2fc934

Browse files
committed
Get rid of METH_OLDARGS.
1 parent 55ac8f0 commit f2fc934

3 files changed

Lines changed: 5 additions & 24 deletions

File tree

Doc/c-api/newtypes.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -255,16 +255,6 @@ convention flags can be combined with a binding flag.
255255
:ctype:`PyObject\*` parameter representing the single argument.
256256

257257

258-
.. XXX deprecated, should be removed
259-
.. data:: METH_OLDARGS
260-
261-
This calling convention is deprecated. The method must be of type
262-
:ctype:`PyCFunction`. The second argument is *NULL* if no arguments are given,
263-
a single object if exactly one argument is given, and a tuple of objects if more
264-
than one argument is given. There is no way for a function using this
265-
convention to distinguish between a call with multiple arguments and a call with
266-
a tuple as the only argument.
267-
268258
These two constants are not used to indicate the calling convention but the
269259
binding when use with methods of classes. These may not be used for functions
270260
defined for modules. At most one of these flags may be set for any given

Include/methodobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ PyAPI_FUNC(PyObject *) PyCFunction_NewEx(PyMethodDef *, PyObject *,
5050
PyObject *);
5151

5252
/* Flag passed to newmethodobject */
53-
#define METH_OLDARGS 0x0000
53+
/* #define METH_OLDARGS 0x0000 -- unsupported now */
5454
#define METH_VARARGS 0x0001
5555
#define METH_KEYWORDS 0x0002
5656
/* METH_NOARGS and METH_O must not be combined with the flags above. */

Objects/methodobject.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ PyCFunction_Call(PyObject *func, PyObject *arg, PyObject *kw)
7373
return (*meth)(self, arg);
7474
break;
7575
case METH_VARARGS | METH_KEYWORDS:
76-
case METH_OLDARGS | METH_KEYWORDS:
7776
return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
7877
case METH_NOARGS:
7978
if (kw == NULL || PyDict_Size(kw) == 0) {
@@ -97,19 +96,11 @@ PyCFunction_Call(PyObject *func, PyObject *arg, PyObject *kw)
9796
return NULL;
9897
}
9998
break;
100-
case METH_OLDARGS:
101-
/* the really old style */
102-
if (kw == NULL || PyDict_Size(kw) == 0) {
103-
size = PyTuple_GET_SIZE(arg);
104-
if (size == 1)
105-
arg = PyTuple_GET_ITEM(arg, 0);
106-
else if (size == 0)
107-
arg = NULL;
108-
return (*meth)(self, arg);
109-
}
110-
break;
11199
default:
112-
PyErr_BadInternalCall();
100+
PyErr_SetString(PyExc_SystemError, "Bad call flags in "
101+
"PyCFunction_Call. METH_OLDARGS is no "
102+
"longer supported!");
103+
113104
return NULL;
114105
}
115106
PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",

0 commit comments

Comments
 (0)