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

numpy-svn at scipy.org numpy-svn at scipy.org
Fri Dec 1 13:33:37 CST 2006


Author: oliphant
Date: 2006-12-01 13:33:05 -0600 (Fri, 01 Dec 2006)
New Revision: 3464

Modified:
   trunk/numpy/core/src/arrayobject.c
Log:
Fix arr.flat[ind] = obj  when ind is 1-element and obj is a 1-element sequence.

Modified: trunk/numpy/core/src/arrayobject.c
===================================================================
--- trunk/numpy/core/src/arrayobject.c	2006-11-30 19:04:09 UTC (rev 3463)
+++ trunk/numpy/core/src/arrayobject.c	2006-12-01 19:33:05 UTC (rev 3464)
@@ -9337,6 +9337,7 @@
                 goto finish;
         }
 
+        if (PySequence_Check(ind) || PySlice_Check(ind)) goto skip;
         start = PyArray_PyIntAsIntp(ind);
         if (start==-1 && PyErr_Occurred()) PyErr_Clear();
         else {
@@ -9350,9 +9351,14 @@
                 PyArray_ITER_GOTO1D(self, start);
                 retval = type->f->setitem(val, self->dataptr, self->ao);
                 PyArray_ITER_RESET(self);
+                if (retval < 0) {
+                        PyErr_SetString(PyExc_ValueError, 
+                                        "Error setting single item of array.");
+                }
                 goto finish;
         }
 
+ skip:
         Py_INCREF(type);
         arrval = PyArray_FromAny(val, type, 0, 0, 0, NULL);
         if (arrval==NULL) return -1;
@@ -9408,7 +9414,7 @@
                 obj = ind;
         }
 
-        if (PyArray_Check(obj)) {
+        if (obj != NULL && PyArray_Check(obj)) {
                 /* Check for Boolean object */
                 if (PyArray_TYPE(obj)==PyArray_BOOL) {
                         if (iter_ass_sub_Bool(self, (PyArrayObject *)obj,



More information about the Numpy-svn mailing list