Skip to content

Commit 09e3ee3

Browse files
committed
restore methodcaller_call
1 parent 83c76bb commit 09e3ee3

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Modules/_operator.c

+28
Original file line numberDiff line numberDiff line change
@@ -1669,6 +1669,33 @@ methodcaller_traverse(methodcallerobject *mc, visitproc visit, void *arg)
16691669
return 0;
16701670
}
16711671

1672+
static PyObject *
1673+
methodcaller_call(methodcallerobject *mc, PyObject *args, PyObject *kw)
1674+
{
1675+
PyObject *method, *obj, *result;
1676+
1677+
if (!_PyArg_NoKeywords("methodcaller", kw))
1678+
return NULL;
1679+
if (!_PyArg_CheckPositional("methodcaller", PyTuple_GET_SIZE(args), 1, 1))
1680+
return NULL;
1681+
obj = PyTuple_GET_ITEM(args, 0);
1682+
method = PyObject_GetAttr(obj, mc->name);
1683+
if (method == NULL)
1684+
return NULL;
1685+
1686+
1687+
PyObject *cargs = PyTuple_GetSlice(mc->xargs, 1, PyTuple_GET_SIZE(mc->xargs));
1688+
if (cargs == NULL) {
1689+
Py_DECREF(method);
1690+
return NULL;
1691+
}
1692+
1693+
result = PyObject_Call(method, cargs, mc->kwds);
1694+
Py_DECREF(cargs);
1695+
Py_DECREF(method);
1696+
return result;
1697+
}
1698+
16721699
static PyObject *
16731700
methodcaller_repr(methodcallerobject *mc)
16741701
{
@@ -1805,6 +1832,7 @@ r.name('date', foo=1).");
18051832
static PyType_Slot methodcaller_type_slots[] = {
18061833
{Py_tp_doc, (void *)methodcaller_doc},
18071834
{Py_tp_dealloc, methodcaller_dealloc},
1835+
{Py_tp_call, methodcaller_call},
18081836
{Py_tp_traverse, methodcaller_traverse},
18091837
{Py_tp_clear, methodcaller_clear},
18101838
{Py_tp_methods, methodcaller_methods},

0 commit comments

Comments
 (0)