Skip to content

Commit

Permalink
Always bind Cython functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jdemeyer committed Aug 28, 2019
1 parent 9170a5a commit 1bb26b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
15 changes: 0 additions & 15 deletions Cython/Utility/CythonFunction.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,21 +552,6 @@ static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit,

static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
{
__pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;

if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
Py_INCREF(func);
return func;
}

if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
if (type == NULL)
type = (PyObject *)(Py_TYPE(obj));
return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
}

if (obj == Py_None)
obj = NULL;
return __Pyx_PyMethod_New(func, obj, type);
}

Expand Down
12 changes: 12 additions & 0 deletions tests/run/cyfunction.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,18 @@ class TestUnboundMethod:
def meth(self): pass
class TestStaticmethod(object):
"""
>>> x = TestStaticmethod()
>>> x.staticmeth(42)
42
>>> x.staticmeth.__get__(42)()
42
"""
@staticmethod
def staticmeth(arg): return arg
cdef class TestOptimisedBuiltinMethod:
"""
>>> obj = TestOptimisedBuiltinMethod()
Expand Down

0 comments on commit 1bb26b9

Please sign in to comment.