summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2020-06-14 12:07:02 +0200
committerStefan Behnel <stefan_ml@behnel.de>2020-06-14 12:07:02 +0200
commit26d45ca806d72efd66a5ed8260d26f17d8c3c717 (patch)
tree44d93a5a7155b147123d4e5229f72d1d00bc4224
parent504779b8391fe92e24a4e25ecdd128517cb29abd (diff)
downloadcython-26d45ca806d72efd66a5ed8260d26f17d8c3c717.tar.gz
Revert "Always bind Cython functions"
This reverts commit 6677326025dcd3acfd4e1e2beabdc678c53dec19.
-rw-r--r--Cython/Utility/CythonFunction.c15
-rw-r--r--tests/run/cyfunction.pyx12
2 files changed, 15 insertions, 12 deletions
diff --git a/Cython/Utility/CythonFunction.c b/Cython/Utility/CythonFunction.c
index edf549127..a65c8eee3 100644
--- a/Cython/Utility/CythonFunction.c
+++ b/Cython/Utility/CythonFunction.c
@@ -548,6 +548,21 @@ 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);
}
diff --git a/tests/run/cyfunction.pyx b/tests/run/cyfunction.pyx
index 4451436ce..3811b2694 100644
--- a/tests/run/cyfunction.pyx
+++ b/tests/run/cyfunction.pyx
@@ -376,18 +376,6 @@ 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()