From c20e8c19d6d2342cefc451c49363f69675992bb4 Mon Sep 17 00:00:00 2001 From: Jeroen Demeyer Date: Wed, 7 Jun 2017 12:19:29 +0200 Subject: [PATCH 1/2] Don't use __Pyx_PyObject_CallMethO on cyfunctions --- Cython/Utility/ObjectHandling.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Cython/Utility/ObjectHandling.c b/Cython/Utility/ObjectHandling.c index 35b5f2e01b9..5e6ad510651 100644 --- a/Cython/Utility/ObjectHandling.c +++ b/Cython/Utility/ObjectHandling.c @@ -1686,11 +1686,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObjec return __Pyx_PyFunction_FastCall(func, &arg, 1); } #endif -#ifdef __Pyx_CyFunction_USED - if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { -#else if (likely(PyCFunction_Check(func))) { -#endif if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { // fast and simple case that we are optimising for return __Pyx_PyObject_CallMethO(func, arg); From 50e7a67366b10a3818d544af9afca9003e4c13a7 Mon Sep 17 00:00:00 2001 From: Jeroen Demeyer Date: Wed, 7 Jun 2017 12:27:57 +0200 Subject: [PATCH 2/2] Add testcase for https://github.com/cython/cython/pull/1728 --- tests/run/cyfunction_METH_O_GH1728.pyx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/run/cyfunction_METH_O_GH1728.pyx diff --git a/tests/run/cyfunction_METH_O_GH1728.pyx b/tests/run/cyfunction_METH_O_GH1728.pyx new file mode 100644 index 00000000000..621fc565fc9 --- /dev/null +++ b/tests/run/cyfunction_METH_O_GH1728.pyx @@ -0,0 +1,16 @@ +# cython: binding=True +# mode: run +# tag: cyfunction + +cdef class TestMethodOneArg: + def meth(self, arg): + pass + +def call_meth(x): + """ + >>> call_meth(TestMethodOneArg()) + Traceback (most recent call last): + ... + TypeError: meth() takes exactly one argument (0 given) + """ + return x.meth()