summaryrefslogtreecommitdiff
path: root/numpy/core/src/arrayobject.c
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-08-14 23:15:21 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-08-14 23:15:21 +0000
commitf77587b2cd9091a99a31bb0d5f99c57cc077aa8e (patch)
tree8894af7b880beece61903e47dd84c7205e3ee8d3 /numpy/core/src/arrayobject.c
parent06acb9555bf64997423b124620fb469cab24cb2b (diff)
downloadnumpy-f77587b2cd9091a99a31bb0d5f99c57cc077aa8e.tar.gz
Fix Python 2.5 compatibility to work with new b3 release
Diffstat (limited to 'numpy/core/src/arrayobject.c')
-rw-r--r--numpy/core/src/arrayobject.c20
1 files changed, 19 insertions, 1 deletions
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 *******************************/