From f77587b2cd9091a99a31bb0d5f99c57cc077aa8e Mon Sep 17 00:00:00 2001 From: Travis Oliphant Date: Mon, 14 Aug 2006 23:15:21 +0000 Subject: Fix Python 2.5 compatibility to work with new b3 release --- numpy/core/src/arrayobject.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'numpy/core/src/arrayobject.c') diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index f0fea6a04..d3bbe9a24 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -3036,7 +3036,7 @@ array_getwritebuf(PyArrayObject *self, Py_ssize_t segment, void **ptrptr) } static Py_ssize_t -array_getcharbuf(PyArrayObject *self, Py_ssize_t segment, const char **ptrptr) +array_getcharbuf(PyArrayObject *self, Py_ssize_t segment, constchar **ptrptr) { if (self->descr->type_num == PyArray_STRING || \ self->descr->type_num == PyArray_UNICODE) @@ -3790,6 +3790,20 @@ _array_copy_nice(PyArrayObject *self) PyArray_Copy(self)); } +#if PY_VERSION_HEX >= 0x02050000 +static PyObject * +array_index(PyArrayObject *v) +{ + if (PyArray_SIZE(v) != 1 || !PyArray_ISINTEGER(v)) { + PyErr_SetString(PyExc_TypeError, "only length-1 integer " \ + "arrays can be converted to an index"); + return NULL; + } + return v->descr->f->getitem(v->data, v); +} +#endif + + static PyNumberMethods array_as_number = { (binaryfunc)array_add, /*nb_add*/ (binaryfunc)array_subtract, /*nb_subtract*/ @@ -3834,6 +3848,10 @@ static PyNumberMethods array_as_number = { (binaryfunc)array_inplace_floor_divide, /*nb_inplace_floor_divide*/ (binaryfunc)array_inplace_true_divide, /*nb_inplace_true_divide*/ +#if PY_VERSION_HEX >= 0x02050000 + (unaryfunc)array_index, /* nb_index */ +#endif + }; /****************** End of Buffer Protocol *******************************/ -- cgit v1.2.1