Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use __Pyx_PyObject_CallMethO on cyfunctions #1728

Merged
merged 2 commits into from Jul 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions Cython/Utility/ObjectHandling.c
Expand Up @@ -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);
Expand Down
16 changes: 16 additions & 0 deletions 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()