Commit a152462e authored by Jeroen Demeyer's avatar Jeroen Demeyer

In Python 3, an unbound method is just the function

parent 969dbad1
......@@ -617,7 +617,7 @@ static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
#endif
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
#else
#define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
......
......@@ -3,6 +3,7 @@
# tag: cyfunction
import sys
IS_PY2 = sys.version_info[0] < 3
IS_PY3 = sys.version_info[0] >= 3
IS_PY34 = sys.version_info > (3, 4, 0, 'beta', 3)
......@@ -348,3 +349,21 @@ cdef class TestDecoratedMethods:
2
"""
return x
cdef class TestUnboundMethodCdef:
"""
>>> C = TestUnboundMethodCdef
>>> IS_PY2 or (C.meth is C.__dict__["meth"])
True
"""
def meth(self): pass
class TestUnboundMethod:
"""
>>> C = TestUnboundMethod
>>> IS_PY2 or (C.meth is C.__dict__["meth"])
True
"""
def meth(self): pass
import sys
IS_PY2 = sys.version_info[0] < 3
import cython
is_compiled = cython.compiled
......@@ -360,3 +363,12 @@ class CClass(object):
def get_attr(self):
print(cython.typeof(self.attr))
return self.attr
class TestUnboundMethod:
"""
>>> C = TestUnboundMethod
>>> IS_PY2 or (C.meth is C.__dict__["meth"])
True
"""
def meth(self): pass
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment