From: Lisandro Dalcin Date: Wed, 14 Oct 2009 23:12:10 +0000 (-0300) Subject: fix for changes in PyXXXDescrObject structures in upcoming Py3.2 X-Git-Tag: 0.13.beta0~2^2~121^2~58 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8d1b692a9becd573a539888ece0c1d2b9e733e14;p=cython.git fix for changes in PyXXXDescrObject structures in upcoming Py3.2 --- diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py index 4c9463d2..0d2360e7 100644 --- a/Cython/Compiler/Symtab.py +++ b/Cython/Compiler/Symtab.py @@ -1450,15 +1450,22 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method) { } if (PyObject_TypeCheck(method, methoddescr_type)) { /* cdef classes */ PyMethodDescrObject *descr = (PyMethodDescrObject *)method; - return PyDescr_NewClassMethod(descr->d_type, descr->d_method); + #if PY_VERSION_HEX < 0x03020000 + PyTypeObject *d_type = descr->d_type; + #else + PyTypeObject *d_type = descr->d_common.d_type; + #endif + return PyDescr_NewClassMethod(d_type, descr->d_method); } - else if (PyMethod_Check(method)) { /* python classes */ + else if (PyMethod_Check(method)) { /* python classes */ return PyClassMethod_New(PyMethod_GET_FUNCTION(method)); } else if (PyCFunction_Check(method)) { return PyClassMethod_New(method); } - PyErr_Format(PyExc_TypeError, "Class-level classmethod() can only be called on a method_descriptor or instance method."); + PyErr_Format(PyExc_TypeError, + "Class-level classmethod() can only be called on" + "a method_descriptor or instance method."); return NULL; } """)