[Numpy-svn] r8362 - trunk/numpy/core/src/multiarray

numpy-svn@scip... numpy-svn@scip...
Sun Apr 25 10:11:01 CDT 2010


Author: charris
Date: 2010-04-25 10:11:00 -0500 (Sun, 25 Apr 2010)
New Revision: 8362

Modified:
   trunk/numpy/core/src/multiarray/methods.c
Log:
BUG: Catch resize shape conversion errors.

Modified: trunk/numpy/core/src/multiarray/methods.c
===================================================================
--- trunk/numpy/core/src/multiarray/methods.c	2010-04-25 14:50:14 UTC (rev 8361)
+++ trunk/numpy/core/src/multiarray/methods.c	2010-04-25 15:11:00 UTC (rev 8362)
@@ -912,7 +912,7 @@
     intp size = PyTuple_Size(args);
     int refcheck = 1;
     PyArray_Dims newshape;
-    PyObject *ret;
+    PyObject *ret, *obj;
 
 
     if (kwds != NULL) {
@@ -929,15 +929,18 @@
         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);



More information about the Numpy-svn mailing list