summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Salvatier <jsalvatier@gmail.com>2012-11-19 19:18:27 -0800
committerJohn Salvatier <jsalvatier@gmail.com>2012-11-19 19:18:27 -0800
commitb86deb746fa996f9311bd02ef6eb0098aba5de70 (patch)
treec6532b742c1d8bcbf8ec8e42fca875cf58e68dfe
parent0db7a4ac73d88b4ef4a717d688a7308f047d277c (diff)
downloadnumpy-b86deb746fa996f9311bd02ef6eb0098aba5de70.tar.gz
gave PyArray_MapIterBind an error code on exit
-rw-r--r--numpy/core/src/multiarray/mapping.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/numpy/core/src/multiarray/mapping.c b/numpy/core/src/multiarray/mapping.c
index 339e1e032..dc703818b 100644
--- a/numpy/core/src/multiarray/mapping.c
+++ b/numpy/core/src/multiarray/mapping.c
@@ -1064,7 +1064,9 @@ array_subscript(PyArrayObject *self, PyObject *op)
Py_DECREF(mit);
return rval;
}
- PyArray_MapIterBind(mit, self);
+ if (!PyArray_MapIterBind(mit, self)) {
+ return NULL;
+ }
other = (PyArrayObject *)PyArray_GetMap(mit);
Py_DECREF(mit);
return (PyObject *)other;
@@ -1328,7 +1330,9 @@ array_ass_sub(PyArrayObject *self, PyObject *ind, PyObject *op)
Py_DECREF(mit);
return rval;
}
- PyArray_MapIterBind(mit, self);
+ if (!PyArray_MapIterBind(mit, self)) {
+ return -1;
+ }
ret = PyArray_SetMap(mit, op);
Py_DECREF(mit);
return ret;
@@ -1697,7 +1701,7 @@ PyArray_MapIterNext(PyArrayMapIterObject *mit)
* Let's do it at bind time and also convert all <0 values to >0 here
* as well.
*/
-NPY_NO_EXPORT void
+NPY_NO_EXPORT int
PyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)
{
int subnd;
@@ -1711,12 +1715,12 @@ PyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)
if (subnd < 0) {
PyErr_SetString(PyExc_IndexError,
"too many indices for array");
- return;
+ goto fail;
}
mit->ait = (PyArrayIterObject *)PyArray_IterNew((PyObject *)arr);
if (mit->ait == NULL) {
- return;
+ return 0;
}
/* no subspace iteration needed. Finish up and Return */
if (subnd == 0) {
@@ -1845,14 +1849,14 @@ PyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)
}
PyArray_ITER_RESET(it);
}
- return;
+ return 0;
fail:
Py_XDECREF(mit->subspace);
Py_XDECREF(mit->ait);
mit->subspace = NULL;
mit->ait = NULL;
- return;
+ return -1;
}
@@ -2047,8 +2051,7 @@ PyArray_MapIterArray(PyArrayObject * a, PyObject * index)
return NULL;
}
- PyArray_MapIterBind(mit, a);
- if (mit->ait == NULL) { /*bind failed*/
+ if (!PyArray_MapIterBind(mit, a)) {
return NULL;
}
PyArray_MapIterReset(mit);