diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2010-04-25 15:11:00 +0000 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2010-04-25 15:11:00 +0000 |
commit | b4b4829dd5daa525f21ac733240b80e5a159bffa (patch) | |
tree | 89e09b9d1d8725f1a76ca9b20f15b54d20bbd47b | |
parent | 84d1bf7bab755b075498b5e7cd70006045352392 (diff) | |
download | numpy-b4b4829dd5daa525f21ac733240b80e5a159bffa.tar.gz |
BUG: Catch resize shape conversion errors.
-rw-r--r-- | numpy/core/src/multiarray/methods.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/numpy/core/src/multiarray/methods.c b/numpy/core/src/multiarray/methods.c index e3fba7efc..5dd555be5 100644 --- a/numpy/core/src/multiarray/methods.c +++ b/numpy/core/src/multiarray/methods.c @@ -912,7 +912,7 @@ array_resize(PyArrayObject *self, PyObject *args, PyObject *kwds) intp size = PyTuple_Size(args); int refcheck = 1; PyArray_Dims newshape; - PyObject *ret; + PyObject *ret, *obj; if (kwds != NULL) { @@ -929,15 +929,18 @@ array_resize(PyArrayObject *self, PyObject *args, PyObject *kwds) return Py_None; } else if (size == 1) { - PyObject *obj = PyTuple_GET_ITEM(args, 0); + obj = PyTuple_GET_ITEM(args, 0); if (obj == Py_None) { Py_INCREF(Py_None); return Py_None; } - PyArray_IntpConverter(obj, &newshape); + args = obj; } - else { - PyArray_IntpConverter(args, &newshape); + if (!PyArray_IntpConverter(args, &newshape)) { + if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, "invalid shape"); + } + return NULL; } ret = PyArray_Resize(self, &newshape, refcheck, PyArray_CORDER); |