@@ -152,17 +152,14 @@ PyCFunction_Call(PyObject *func, PyObject *args, PyObject *kwds)
152152}
153153
154154PyObject *
155- _PyCFunction_FastCallDict ( PyObject * func_obj , PyObject * * args , Py_ssize_t nargs ,
156- PyObject * kwargs )
155+ _PyMethodDef_RawFastCallDict ( PyMethodDef * method , PyObject * self , PyObject * * args ,
156+ Py_ssize_t nargs , PyObject * kwargs )
157157{
158- PyCFunctionObject * func ;
159158 PyCFunction meth ;
160- PyObject * self ;
161159 PyObject * result ;
162160 int flags ;
163161
164- assert (func_obj != NULL );
165- assert (PyCFunction_Check (func_obj ));
162+ assert (method != NULL );
166163 assert (nargs >= 0 );
167164 assert (nargs == 0 || args != NULL );
168165 assert (kwargs == NULL || PyDict_Check (kwargs ));
@@ -172,10 +169,8 @@ _PyCFunction_FastCallDict(PyObject *func_obj, PyObject **args, Py_ssize_t nargs,
172169 caller loses its exception */
173170 assert (!PyErr_Occurred ());
174171
175- func = (PyCFunctionObject * )func_obj ;
176- meth = PyCFunction_GET_FUNCTION (func );
177- self = PyCFunction_GET_SELF (func );
178- flags = PyCFunction_GET_FLAGS (func ) & ~(METH_CLASS | METH_STATIC | METH_COEXIST );
172+ meth = method -> ml_meth ;
173+ flags = method -> ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST );
179174
180175 switch (flags )
181176 {
@@ -186,7 +181,7 @@ _PyCFunction_FastCallDict(PyObject *func_obj, PyObject **args, Py_ssize_t nargs,
186181
187182 if (kwargs != NULL && PyDict_GET_SIZE (kwargs ) != 0 ) {
188183 PyErr_Format (PyExc_TypeError , "%.200s() takes no keyword arguments" ,
189- func -> m_ml -> ml_name );
184+ method -> ml_name );
190185 return NULL ;
191186 }
192187
@@ -197,7 +192,7 @@ _PyCFunction_FastCallDict(PyObject *func_obj, PyObject **args, Py_ssize_t nargs,
197192 if (nargs != 1 ) {
198193 PyErr_Format (PyExc_TypeError ,
199194 "%.200s() takes exactly one argument (%zd given)" ,
200- func -> m_ml -> ml_name , nargs );
195+ method -> ml_name , nargs );
201196 return NULL ;
202197 }
203198
@@ -259,17 +254,31 @@ _PyCFunction_FastCallDict(PyObject *func_obj, PyObject **args, Py_ssize_t nargs,
259254 return NULL ;
260255 }
261256
262- result = _Py_CheckFunctionResult (func_obj , result , NULL );
263-
264257 return result ;
265258
266259no_keyword_error :
267260 PyErr_Format (PyExc_TypeError ,
268261 "%.200s() takes no arguments (%zd given)" ,
269- func -> m_ml -> ml_name , nargs );
262+ method -> ml_name , nargs );
270263 return NULL ;
271264}
272265
266+ PyObject *
267+ _PyCFunction_FastCallDict (PyObject * func , PyObject * * args , Py_ssize_t nargs ,
268+ PyObject * kwargs )
269+ {
270+ PyObject * result ;
271+
272+ assert (func != NULL );
273+ assert (PyCFunction_Check (func ));
274+
275+ result = _PyMethodDef_RawFastCallDict (((PyCFunctionObject * )func )-> m_ml ,
276+ PyCFunction_GET_SELF (func ),
277+ args , nargs , kwargs );
278+ result = _Py_CheckFunctionResult (func , result , NULL );
279+ return result ;
280+ }
281+
273282PyObject *
274283_PyCFunction_FastCallKeywords (PyObject * func_obj , PyObject * * args ,
275284 Py_ssize_t nargs , PyObject * kwnames )
0 commit comments