diff options
Diffstat (limited to 'Objects/methodobject.c')
-rw-r--r-- | Objects/methodobject.c | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/Objects/methodobject.c b/Objects/methodobject.c index 56fbcc2..9d43044 100644 --- a/Objects/methodobject.c +++ b/Objects/methodobject.c @@ -56,6 +56,40 @@ PyCFunction_GetFlags(PyObject *op) return ((PyCFunctionObject *)op) -> m_ml -> ml_flags; } +PyObject * +PyCFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) +{ + PyCFunctionObject* f = (PyCFunctionObject*)func; + PyCFunction meth = PyCFunction_GET_FUNCTION(func); + PyObject *self = PyCFunction_GET_SELF(func); + int flags = PyCFunction_GET_FLAGS(func); + + if (flags & METH_KEYWORDS) { + return (*(PyCFunctionWithKeywords)meth)(self, arg, kw); + } + if (kw != NULL && PyDict_Size(kw) != 0) { + PyErr_Format(PyExc_TypeError, + "%.200s() takes no keyword arguments", + f->m_ml->ml_name); + return NULL; + } + if (flags & METH_VARARGS) { + return (*meth)(self, arg); + } + if (!(flags & METH_VARARGS)) { + /* the really old style */ + int size = PyTuple_GET_SIZE(arg); + if (size == 1) + arg = PyTuple_GET_ITEM(arg, 0); + else if (size == 0) + arg = NULL; + return (*meth)(self, arg); + } + /* should never get here ??? */ + PyErr_BadInternalCall(); + return NULL; +} + /* Methods (the standard built-in methods, that is) */ static void @@ -163,40 +197,6 @@ meth_hash(PyCFunctionObject *a) return x; } -static PyObject * -meth_call(PyObject *func, PyObject *arg, PyObject *kw) -{ - PyCFunctionObject* f = (PyCFunctionObject*)func; - PyCFunction meth = PyCFunction_GET_FUNCTION(func); - PyObject *self = PyCFunction_GET_SELF(func); - int flags = PyCFunction_GET_FLAGS(func); - - if (flags & METH_KEYWORDS) { - return (*(PyCFunctionWithKeywords)meth)(self, arg, kw); - } - if (kw != NULL && PyDict_Size(kw) != 0) { - PyErr_Format(PyExc_TypeError, - "%.200s() takes no keyword arguments", - f->m_ml->ml_name); - return NULL; - } - if (flags & METH_VARARGS) { - return (*meth)(self, arg); - } - if (!(flags & METH_VARARGS)) { - /* the really old style */ - int size = PyTuple_GET_SIZE(arg); - if (size == 1) - arg = PyTuple_GET_ITEM(arg, 0); - else if (size == 0) - arg = NULL; - return (*meth)(self, arg); - } - /* should never get here ??? */ - PyErr_BadInternalCall(); - return NULL; -} - PyTypeObject PyCFunction_Type = { PyObject_HEAD_INIT(&PyType_Type) @@ -214,7 +214,7 @@ PyTypeObject PyCFunction_Type = { 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ (hashfunc)meth_hash, /* tp_hash */ - meth_call, /* tp_call */ + PyCFunction_Call, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ |