[Numpy-svn] r2939 - trunk/numpy/core/src

numpy-svn at scipy.org numpy-svn at scipy.org
Mon Jul 31 19:35:04 EDT 2006


Author: oliphant
Date: 2006-07-31 18:35:02 -0500 (Mon, 31 Jul 2006)
New Revision: 2939

Modified:
   trunk/numpy/core/src/arrayobject.c
Log:
Fix ticket #218

Modified: trunk/numpy/core/src/arrayobject.c
===================================================================
--- trunk/numpy/core/src/arrayobject.c	2006-07-31 22:26:25 UTC (rev 2938)
+++ trunk/numpy/core/src/arrayobject.c	2006-07-31 23:35:02 UTC (rev 2939)
@@ -5982,15 +5982,22 @@
                 PyErr_SetString(PyExc_TypeError, "invalid data-type for array");
                 return -1;
         }
-        if (newtype->type_num == PyArray_OBJECT || \
-            self->descr->type_num == PyArray_OBJECT) {
-                PyErr_SetString(PyExc_TypeError, \
-                                "Cannot change descriptor for object"\
+        if (newtype->hasobject || self->descr->hasobject) {
+                PyErr_SetString(PyExc_TypeError,                        \
+                                "Cannot change data-type for object"    \
                                 "array.");
                 Py_DECREF(newtype);
                 return -1;
         }
 
+        if (newtype->elsize == 0) {
+                PyErr_SetString(PyExc_TypeError, 
+                                "data-type must not be 0-sized");
+                Py_DECREF(newtype);
+                return -1;
+        }
+
+
         if ((newtype->elsize != self->descr->elsize) &&         \
             (self->nd == 0 || !PyArray_ISONESEGMENT(self) || \
              newtype->subarray)) goto fail;




More information about the Numpy-svn mailing list