Commit 924177f7 authored by Stefan Behnel's avatar Stefan Behnel

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

parent 7ee7a39c
...@@ -1459,7 +1459,8 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method) { ...@@ -1459,7 +1459,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 (unlikely(methoddescr_type == NULL)) { if (unlikely(methoddescr_type == NULL)) {
PyObject *meth = PyObject_GetAttrString((PyObject*)&PyList_Type, "append"); PyObject *meth = PyObject_GetAttrString((PyObject*)&PyList_Type, "append");
...@@ -1467,6 +1468,9 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method) { ...@@ -1467,6 +1468,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