@@ -215,40 +215,32 @@ _PyCFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs,
215215}
216216
217217PyObject *
218- _PyCFunction_FastCallKeywords ( PyObject * func_obj , PyObject * * args ,
219- Py_ssize_t nargs , PyObject * kwnames )
218+ _PyMethodDef_RawFastCallKeywords ( PyMethodDef * method , PyObject * self , PyObject * * args ,
219+ Py_ssize_t nargs , PyObject * kwnames )
220220{
221- PyCFunctionObject * func ;
222- PyCFunction meth ;
223- PyObject * self , * result ;
224- Py_ssize_t nkwargs = (kwnames == NULL ) ? 0 : PyTuple_GET_SIZE (kwnames );
225- int flags ;
221+ /* _PyMethodDef_RawFastCallKeywords() must not be called with an exception set,
222+ because it can clear it (directly or indirectly) and so the
223+ caller loses its exception */
224+ assert (!PyErr_Occurred ());
226225
227- assert (func_obj != NULL );
228- assert (PyCFunction_Check (func_obj ));
226+ assert (method != NULL );
229227 assert (nargs >= 0 );
230228 assert (kwnames == NULL || PyTuple_CheckExact (kwnames ));
231- assert ((nargs == 0 && nkwargs == 0 ) || args != NULL );
232229 /* kwnames must only contains str strings, no subclass, and all keys must
233230 be unique */
234231
235- /* _PyCFunction_FastCallKeywords() must not be called with an exception
236- set, because it can clear it (directly or indirectly) and so the caller
237- loses its exception */
238- assert (!PyErr_Occurred ());
239-
240- func = (PyCFunctionObject * )func_obj ;
241- meth = PyCFunction_GET_FUNCTION (func );
242- self = PyCFunction_GET_SELF (func );
243- flags = PyCFunction_GET_FLAGS (func ) & ~(METH_CLASS | METH_STATIC | METH_COEXIST );
232+ PyCFunction meth = method -> ml_meth ;
233+ int flags = method -> ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST );
234+ Py_ssize_t nkwargs = kwnames == NULL ? 0 : PyTuple_Size (kwnames );
235+ PyObject * result ;
244236
245237 switch (flags )
246238 {
247239 case METH_NOARGS :
248240 if (nargs != 0 ) {
249241 PyErr_Format (PyExc_TypeError ,
250242 "%.200s() takes no arguments (%zd given)" ,
251- func -> m_ml -> ml_name , nargs );
243+ method -> ml_name , nargs );
252244 return NULL ;
253245 }
254246
@@ -263,7 +255,7 @@ _PyCFunction_FastCallKeywords(PyObject *func_obj, PyObject **args,
263255 if (nargs != 1 ) {
264256 PyErr_Format (PyExc_TypeError ,
265257 "%.200s() takes exactly one argument (%zd given)" ,
266- func -> m_ml -> ml_name , nargs );
258+ method -> ml_name , nargs );
267259 return NULL ;
268260 }
269261
@@ -326,16 +318,31 @@ _PyCFunction_FastCallKeywords(PyObject *func_obj, PyObject **args,
326318 return NULL ;
327319 }
328320
329- result = _Py_CheckFunctionResult (func_obj , result , NULL );
330321 return result ;
331322
332323no_keyword_error :
333324 PyErr_Format (PyExc_TypeError ,
334325 "%.200s() takes no keyword arguments" ,
335- func -> m_ml -> ml_name );
326+ method -> ml_name );
336327 return NULL ;
337328}
338329
330+ PyObject *
331+ _PyCFunction_FastCallKeywords (PyObject * func , PyObject * * args ,
332+ Py_ssize_t nargs , PyObject * kwnames )
333+ {
334+ PyObject * result ;
335+
336+ assert (func != NULL );
337+ assert (PyCFunction_Check (func ));
338+
339+ result = _PyMethodDef_RawFastCallKeywords (((PyCFunctionObject * )func )-> m_ml ,
340+ PyCFunction_GET_SELF (func ),
341+ args , nargs , kwnames );
342+ result = _Py_CheckFunctionResult (func , result , NULL );
343+ return result ;
344+ }
345+
339346/* Methods (the standard built-in methods, that is) */
340347
341348static void
0 commit comments