summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorHan Genuit <hangenuit@gmail.com>2011-10-28 15:31:44 +0200
committerSebastian Berg <sebastian@sipsolutions.net>2013-04-11 16:56:43 +0200
commitbc925023af236fa02702afd1a11dd0342ad77e5d (patch)
treebb902cd3b8b4dee5e9f4c359c3229b47931a6136 /numpy
parent9442b91d13803a2862d7bbb29f8da50200df333b (diff)
downloadnumpy-bc925023af236fa02702afd1a11dd0342ad77e5d.tar.gz
ENH: Change IndexError to ValueError for integer conversion errors.
Conflicts: numpy/core/src/multiarray/mapping.c
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/multiarray/mapping.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/numpy/core/src/multiarray/mapping.c b/numpy/core/src/multiarray/mapping.c
index 7429dc25a..7dc17f7c4 100644
--- a/numpy/core/src/multiarray/mapping.c
+++ b/numpy/core/src/multiarray/mapping.c
@@ -1065,7 +1065,8 @@ array_subscript_fromobject(PyArrayObject *self, PyObject *op)
npy_intp value = PyArray_PyIntAsIntp(op);
if (value == -1 && PyErr_Occurred()) {
/* fail on error */
- PyErr_SetString(PyExc_IndexError, "integer index out of bounds");
+ PyErr_SetString(PyExc_ValueError,
+ "cannot convert index to integer");
return NULL;
}
else {
@@ -1205,7 +1206,8 @@ array_subscript_fromobject(PyArrayObject *self, PyObject *op)
NULL);
}
}
- PyErr_SetString(PyExc_IndexError, "0-dimensional arrays can't be indexed");
+ PyErr_SetString(PyExc_IndexError,
+ "0-dimensional arrays can't be indexed");
return NULL;
}
@@ -1236,7 +1238,8 @@ array_subscript(PyArrayObject *self, PyObject *op)
}
/* Error case when indexing 0-dim array with non-boolean. */
else if (PyArray_NDIM(self) == 0) {
- PyErr_SetString(PyExc_IndexError, "0-dimensional arrays can't be indexed");
+ PyErr_SetString(PyExc_IndexError,
+ "0-dimensional arrays can't be indexed");
return NULL;
}
@@ -1378,7 +1381,8 @@ array_ass_sub(PyArrayObject *self, PyObject *ind, PyObject *op)
npy_intp value = PyArray_PyIntAsIntp(ind);
if (value == -1 && PyErr_Occurred()) {
/* fail on error */
- PyErr_SetString(PyExc_IndexError, "integer index out of bounds");
+ PyErr_SetString(PyExc_ValueError,
+ "cannot convert index to integer");
return -1;
}
else {
@@ -1457,7 +1461,8 @@ array_ass_sub(PyArrayObject *self, PyObject *ind, PyObject *op)
return 0;
}
}
- PyErr_SetString(PyExc_IndexError, "0-dimensional arrays can't be indexed.");
+ PyErr_SetString(PyExc_IndexError,
+ "0-dimensional arrays can't be indexed.");
return -1;
}