Commit 12ab8bc0 authored by da-woods's avatar da-woods Committed by GitHub

classmethod() should fall back to calling PyClassMethod_New() instead of...

classmethod() should fall back to calling PyClassMethod_New() instead of deciding for itself that the type is invalid. (GH-3660)
parent ef423d1e
......@@ -1484,16 +1484,8 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
// python classes
return PyClassMethod_New(PyMethod_GET_FUNCTION(method));
}
#ifdef __Pyx_CyFunction_USED
else if (__Pyx_IsCyOrPyCFunction(method))
#else
else if (PyCFunction_Check(method))
#endif
else
{
return PyClassMethod_New(method);
}
PyErr_SetString(PyExc_TypeError,
"Class-level classmethod() can only be called on "
"a method_descriptor or instance method.");
return NULL;
}
......@@ -9,6 +9,10 @@ class1
class1
>>> class1().bview()
class1
>>> class1().cview()
class1
>>> class1().cview("XX")
class1XX
>>> class2.view()
class2
......@@ -35,6 +39,12 @@ cimport cython
def f_plus(cls, a):
return cls.a + a
def second_decorator(f):
# note - a class, not a function (didn't pass Cython's test in __Pyx_Method_ClassMethod)
class C:
def __call__(self, *args):
return f(*args)
return C()
class class1:
a = 5
......@@ -48,6 +58,11 @@ class class1:
def bview(cls):
print cls.__name__
@classmethod
@second_decorator
def cview(cls, s=""):
print cls.__name__+s
class class2(object):
a = 6
......
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