Commit 3a6b9856 authored by Stefan Behnel's avatar Stefan Behnel

remove dead Py2.7+ code in <Py2.6 only code blocks and clean them up a bit

parent 553bed86
...@@ -107,8 +107,6 @@ typedef struct { ...@@ -107,8 +107,6 @@ typedef struct {
/////////////// GetAndReleaseBuffer /////////////// /////////////// GetAndReleaseBuffer ///////////////
#if PY_MAJOR_VERSION < 3 #if PY_MAJOR_VERSION < 3
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
CYTHON_UNUSED PyObject *getbuffer_cobj;
#if PY_VERSION_HEX >= 0x02060000 #if PY_VERSION_HEX >= 0x02060000
if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags);
#endif #endif
...@@ -120,23 +118,19 @@ static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { ...@@ -120,23 +118,19 @@ static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
{{endfor}} {{endfor}}
#if PY_VERSION_HEX < 0x02060000 #if PY_VERSION_HEX < 0x02060000
if (obj->ob_type->tp_dict && if (obj->ob_type->tp_dict) {
(getbuffer_cobj = PyObject_GetItem(obj->ob_type->tp_dict, PyObject *getbuffer_cobj = PyObject_GetItem(
PYIDENT("__pyx_getbuffer")))) { obj->ob_type->tp_dict, PYIDENT("__pyx_getbuffer"));
getbufferproc func; if (getbuffer_cobj) {
getbufferproc func = (getbufferproc) PyCObject_AsVoidPtr(getbuffer_cobj);
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 0) Py_DECREF(getbuffer_cobj);
func = (getbufferproc) PyCapsule_GetPointer(getbuffer_cobj, "getbuffer(obj, view, flags)"); if (!func)
#else goto fail;
func = (getbufferproc) PyCObject_AsVoidPtr(getbuffer_cobj);
#endif return func(obj, view, flags);
Py_DECREF(getbuffer_cobj); } else {
if (!func) PyErr_Clear();
goto fail; }
return func(obj, view, flags);
} else {
PyErr_Clear();
} }
#endif #endif
...@@ -151,8 +145,6 @@ fail: ...@@ -151,8 +145,6 @@ fail:
static void __Pyx_ReleaseBuffer(Py_buffer *view) { static void __Pyx_ReleaseBuffer(Py_buffer *view) {
PyObject *obj = view->obj; PyObject *obj = view->obj;
CYTHON_UNUSED PyObject *releasebuffer_cobj;
if (!obj) return; if (!obj) return;
#if PY_VERSION_HEX >= 0x02060000 #if PY_VERSION_HEX >= 0x02060000
...@@ -169,26 +161,19 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { ...@@ -169,26 +161,19 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) {
{{endfor}} {{endfor}}
#if PY_VERSION_HEX < 0x02060000 #if PY_VERSION_HEX < 0x02060000
if (obj->ob_type->tp_dict && if (obj->ob_type->tp_dict) {
(releasebuffer_cobj = PyObject_GetItem(obj->ob_type->tp_dict, PyObject *releasebuffer_cobj = PyObject_GetItem(
PYIDENT("__pyx_releasebuffer")))) { obj->ob_type->tp_dict, PYIDENT("__pyx_releasebuffer"));
releasebufferproc func; if (releasebuffer_cobj) {
releasebufferproc func = (releasebufferproc) PyCObject_AsVoidPtr(releasebuffer_cobj);
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 0) Py_DECREF(releasebuffer_cobj);
func = (releasebufferproc) PyCapsule_GetPointer(releasebuffer_cobj, "releasebuffer(obj, view)"); if (!func)
#else goto fail;
func = (releasebufferproc) PyCObject_AsVoidPtr(releasebuffer_cobj); func(obj, view);
#endif return;
} else {
Py_DECREF(releasebuffer_cobj); PyErr_Clear();
}
if (!func)
goto fail;
func(obj, view);
return;
} else {
PyErr_Clear();
} }
#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