summaryrefslogtreecommitdiffstats
path: root/Objects/call.c
diff options
context:
space:
mode:
authorJeroen Demeyer <J.Demeyer@UGent.be>2019-09-11 11:01:01 (GMT)
committerPetr Viktorin <encukou@gmail.com>2019-09-11 11:01:01 (GMT)
commit7a6873cdb1f496447ac5d57ae457eacbb56b7972 (patch)
treea2a7e401399f18067c5b41f24f86d8deaf7f22c6 /Objects/call.c
parent2d8d597bb8f882a7677db5a2739df0e617098634 (diff)
downloadcpython-7a6873cdb1f496447ac5d57ae457eacbb56b7972.zip
cpython-7a6873cdb1f496447ac5d57ae457eacbb56b7972.tar.gz
cpython-7a6873cdb1f496447ac5d57ae457eacbb56b7972.tar.bz2
bpo-37151: remove special case for PyCFunction from PyObject_Call (GH-14684)
bpo-37151: remove special case for PyCFunction from PyObject_Call Alse, make the undocumented function PyCFunction_Call an alias of PyObject_Call and deprecate it.
Diffstat (limited to 'Objects/call.c')
-rw-r--r--Objects/call.c69
1 files changed, 7 insertions, 62 deletions
diff --git a/Objects/call.c b/Objects/call.c
index 8a60b3e..a715bcb 100644
--- a/Objects/call.c
+++ b/Objects/call.c
@@ -5,9 +5,6 @@
#include "frameobject.h"
-static PyObject *
-cfunction_call_varargs(PyObject *func, PyObject *args, PyObject *kwargs);
-
static PyObject *const *
_PyStack_UnpackDict(PyObject *const *args, Py_ssize_t nargs, PyObject *kwargs,
PyObject **p_kwnames);
@@ -236,11 +233,6 @@ PyObject_Call(PyObject *callable, PyObject *args, PyObject *kwargs)
if (_PyVectorcall_Function(callable) != NULL) {
return PyVectorcall_Call(callable, args, kwargs);
}
- else if (PyCFunction_Check(callable)) {
- /* This must be a METH_VARARGS function, otherwise we would be
- * in the previous case */
- return cfunction_call_varargs(callable, args, kwargs);
- }
else {
call = callable->ob_type->tp_call;
if (call == NULL) {
@@ -261,6 +253,13 @@ PyObject_Call(PyObject *callable, PyObject *args, PyObject *kwargs)
}
+PyObject *
+PyCFunction_Call(PyObject *callable, PyObject *args, PyObject *kwargs)
+{
+ return PyObject_Call(callable, args, kwargs);
+}
+
+
/* --- PyFunction call functions ---------------------------------- */
static PyObject* _Py_HOT_FUNCTION
@@ -363,60 +362,6 @@ _PyFunction_Vectorcall(PyObject *func, PyObject* const* stack,
}
-/* --- PyCFunction call functions --------------------------------- */
-
-static PyObject *
-cfunction_call_varargs(PyObject *func, PyObject *args, PyObject *kwargs)
-{
- assert(!PyErr_Occurred());
- assert(kwargs == NULL || PyDict_Check(kwargs));
-
- PyCFunction meth = PyCFunction_GET_FUNCTION(func);
- PyObject *self = PyCFunction_GET_SELF(func);
- PyObject *result;
-
- assert(PyCFunction_GET_FLAGS(func) & METH_VARARGS);
- if (PyCFunction_GET_FLAGS(func) & METH_KEYWORDS) {
- if (Py_EnterRecursiveCall(" while calling a Python object")) {
- return NULL;
- }
-
- result = (*(PyCFunctionWithKeywords)(void(*)(void))meth)(self, args, kwargs);
-
- Py_LeaveRecursiveCall();
- }
- else {
- if (kwargs != NULL && PyDict_GET_SIZE(kwargs) != 0) {
- PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
- ((PyCFunctionObject*)func)->m_ml->ml_name);
- return NULL;
- }
-
- if (Py_EnterRecursiveCall(" while calling a Python object")) {
- return NULL;
- }
-
- result = (*meth)(self, args);
-
- Py_LeaveRecursiveCall();
- }
-
- return _Py_CheckFunctionResult(func, result, NULL);
-}
-
-
-PyObject *
-PyCFunction_Call(PyObject *func, PyObject *args, PyObject *kwargs)
-{
- /* For METH_VARARGS, we cannot use vectorcall as the vectorcall pointer
- * is NULL. This is intentional, since vectorcall would be slower. */
- if (PyCFunction_GET_FLAGS(func) & METH_VARARGS) {
- return cfunction_call_varargs(func, args, kwargs);
- }
- return PyVectorcall_Call(func, args, kwargs);
-}
-
-
/* --- More complex call functions -------------------------------- */
/* External interface to call any callable object.