Commit 09979e15 authored by Stefan Behnel's avatar Stefan Behnel

Simplify classmethod() code in Py3 where "PyMethodDescr_Type" is directly available.

parent 8359cf76
...@@ -1292,7 +1292,8 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method) { ...@@ -1292,7 +1292,8 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
// special C-API function only in Pyston and PyPy >= 5.9 // special C-API function only in Pyston and PyPy >= 5.9
if (PyMethodDescr_Check(method)) if (PyMethodDescr_Check(method))
#else #else
// It appears that PyMethodDescr_Type is not exposed anywhere in the CPython C-API #if PY_MAJOR_VERSION == 2
// PyMethodDescr_Type is not exposed in the CPython C-API in Py2.
static PyTypeObject *methoddescr_type = NULL; static PyTypeObject *methoddescr_type = NULL;
if (methoddescr_type == NULL) { if (methoddescr_type == NULL) {
PyObject *meth = PyObject_GetAttrString((PyObject*)&PyList_Type, "append"); PyObject *meth = PyObject_GetAttrString((PyObject*)&PyList_Type, "append");
...@@ -1300,6 +1301,9 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method) { ...@@ -1300,6 +1301,9 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
methoddescr_type = Py_TYPE(meth); methoddescr_type = Py_TYPE(meth);
Py_DECREF(meth); Py_DECREF(meth);
} }
#else
PyTypeObject *methoddescr_type = &PyMethodDescr_Type;
#endif
if (__Pyx_TypeCheck(method, methoddescr_type)) if (__Pyx_TypeCheck(method, methoddescr_type))
#endif #endif
{ {
......
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