55#include "frameobject.h"
66
77
8- static PyObject *
9- cfunction_call_varargs (PyObject * func , PyObject * args , PyObject * kwargs );
10-
118static PyObject * const *
129_PyStack_UnpackDict (PyObject * const * args , Py_ssize_t nargs , PyObject * kwargs ,
1310 PyObject * * p_kwnames );
@@ -236,11 +233,6 @@ PyObject_Call(PyObject *callable, PyObject *args, PyObject *kwargs)
236233 if (_PyVectorcall_Function (callable ) != NULL ) {
237234 return PyVectorcall_Call (callable , args , kwargs );
238235 }
239- else if (PyCFunction_Check (callable )) {
240- /* This must be a METH_VARARGS function, otherwise we would be
241- * in the previous case */
242- return cfunction_call_varargs (callable , args , kwargs );
243- }
244236 else {
245237 call = callable -> ob_type -> tp_call ;
246238 if (call == NULL ) {
@@ -261,6 +253,13 @@ PyObject_Call(PyObject *callable, PyObject *args, PyObject *kwargs)
261253}
262254
263255
256+ PyObject *
257+ PyCFunction_Call (PyObject * callable , PyObject * args , PyObject * kwargs )
258+ {
259+ return PyObject_Call (callable , args , kwargs );
260+ }
261+
262+
264263/* --- PyFunction call functions ---------------------------------- */
265264
266265static PyObject * _Py_HOT_FUNCTION
@@ -363,60 +362,6 @@ _PyFunction_Vectorcall(PyObject *func, PyObject* const* stack,
363362}
364363
365364
366- /* --- PyCFunction call functions --------------------------------- */
367-
368- static PyObject *
369- cfunction_call_varargs (PyObject * func , PyObject * args , PyObject * kwargs )
370- {
371- assert (!PyErr_Occurred ());
372- assert (kwargs == NULL || PyDict_Check (kwargs ));
373-
374- PyCFunction meth = PyCFunction_GET_FUNCTION (func );
375- PyObject * self = PyCFunction_GET_SELF (func );
376- PyObject * result ;
377-
378- assert (PyCFunction_GET_FLAGS (func ) & METH_VARARGS );
379- if (PyCFunction_GET_FLAGS (func ) & METH_KEYWORDS ) {
380- if (Py_EnterRecursiveCall (" while calling a Python object" )) {
381- return NULL ;
382- }
383-
384- result = (* (PyCFunctionWithKeywords )(void (* )(void ))meth )(self , args , kwargs );
385-
386- Py_LeaveRecursiveCall ();
387- }
388- else {
389- if (kwargs != NULL && PyDict_GET_SIZE (kwargs ) != 0 ) {
390- PyErr_Format (PyExc_TypeError , "%.200s() takes no keyword arguments" ,
391- ((PyCFunctionObject * )func )-> m_ml -> ml_name );
392- return NULL ;
393- }
394-
395- if (Py_EnterRecursiveCall (" while calling a Python object" )) {
396- return NULL ;
397- }
398-
399- result = (* meth )(self , args );
400-
401- Py_LeaveRecursiveCall ();
402- }
403-
404- return _Py_CheckFunctionResult (func , result , NULL );
405- }
406-
407-
408- PyObject *
409- PyCFunction_Call (PyObject * func , PyObject * args , PyObject * kwargs )
410- {
411- /* For METH_VARARGS, we cannot use vectorcall as the vectorcall pointer
412- * is NULL. This is intentional, since vectorcall would be slower. */
413- if (PyCFunction_GET_FLAGS (func ) & METH_VARARGS ) {
414- return cfunction_call_varargs (func , args , kwargs );
415- }
416- return PyVectorcall_Call (func , args , kwargs );
417- }
418-
419-
420365/* --- More complex call functions -------------------------------- */
421366
422367/* External interface to call any callable object.
0 commit comments