summaryrefslogtreecommitdiff
path: root/numpy/core/src
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-12-01 19:33:05 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-12-01 19:33:05 +0000
commit5898c2c445cb7fe14e2866b34f625e6f95bbf82f (patch)
tree51a98d3c40c93ce549b6e68cc1ca7e2a9b40b724 /numpy/core/src
parent7ba40d2928695a751ae24c05a6b7f2fb7aa97f88 (diff)
downloadnumpy-5898c2c445cb7fe14e2866b34f625e6f95bbf82f.tar.gz
Fix arr.flat[ind] = obj when ind is 1-element and obj is a 1-element sequence.
Diffstat (limited to 'numpy/core/src')
-rw-r--r--numpy/core/src/arrayobject.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c
index 4b6ae3a6f..0485e5ad3 100644
--- a/numpy/core/src/arrayobject.c
+++ b/numpy/core/src/arrayobject.c
@@ -9337,6 +9337,7 @@ iter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val)
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 @@ iter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val)
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 @@ iter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val)
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,