@@ -1669,6 +1669,33 @@ methodcaller_traverse(methodcallerobject *mc, visitproc visit, void *arg)
1669
1669
return 0 ;
1670
1670
}
1671
1671
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
+
1672
1699
static PyObject *
1673
1700
methodcaller_repr (methodcallerobject * mc )
1674
1701
{
@@ -1805,6 +1832,7 @@ r.name('date', foo=1).");
1805
1832
static PyType_Slot methodcaller_type_slots [] = {
1806
1833
{Py_tp_doc , (void * )methodcaller_doc },
1807
1834
{Py_tp_dealloc , methodcaller_dealloc },
1835
+ {Py_tp_call , methodcaller_call },
1808
1836
{Py_tp_traverse , methodcaller_traverse },
1809
1837
{Py_tp_clear , methodcaller_clear },
1810
1838
{Py_tp_methods , methodcaller_methods },
0 commit comments