summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorMark Wiebe <mwwiebe@gmail.com>2013-01-07 16:15:57 -0800
committerMark Wiebe <mwwiebe@gmail.com>2013-08-12 16:28:22 -0700
commit8c0c77549355a0b6d9d1194467f819893d27eb51 (patch)
treeb16f4382de4171fe315f54ad011c284c30341ee5 /numpy/core
parent66ad5a1b50e19cd75ada459e997da85fed7952bd (diff)
downloadnumpy-8c0c77549355a0b6d9d1194467f819893d27eb51.tar.gz
BUG: Fix to allow x.fill(tuple) where x is a struct array
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/src/multiarray/convert.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/convert.c b/numpy/core/src/multiarray/convert.c
index e3dd78b9f..62b9034c2 100644
--- a/numpy/core/src/multiarray/convert.c
+++ b/numpy/core/src/multiarray/convert.c
@@ -413,7 +413,14 @@ PyArray_FillWithScalar(PyArrayObject *arr, PyObject *obj)
else {
PyArrayObject *src_arr;
- src_arr = (PyArrayObject *)PyArray_FromAny(obj, NULL, 0, 0, 0, NULL);
+ /**
+ * The dtype of the destination is used when converting
+ * from the pyobject, so that for example a tuple gets
+ * recognized as a struct scalar of the required type.
+ */
+ Py_INCREF(PyArray_DTYPE(arr));
+ src_arr = (PyArrayObject *)PyArray_FromAny(obj,
+ PyArray_DTYPE(arr), 0, 0, 0, NULL);
if (src_arr == NULL) {
return -1;
}