diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-01-30 09:20:46 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-01-30 09:20:46 +0000 |
commit | ca90e3eba3c94de3bd13266ccfd9f96dbf23693a (patch) | |
tree | 9284732d8d1161b37191d37eb96b17ab2197072a | |
parent | 624787ad6dbdf9cd73749f29092d05e0f716f12c (diff) | |
download | numpy-ca90e3eba3c94de3bd13266ccfd9f96dbf23693a.tar.gz |
Fix-up record arrays that were not of dtype.type record. Don't allow arbitrary objects with dtype attributes as data-type indicators.
-rw-r--r-- | numpy/core/records.py | 9 | ||||
-rw-r--r-- | numpy/core/src/multiarraymodule.c | 4 |
2 files changed, 9 insertions, 4 deletions
diff --git a/numpy/core/records.py b/numpy/core/records.py index c646402a0..73a80f255 100644 --- a/numpy/core/records.py +++ b/numpy/core/records.py @@ -294,7 +294,10 @@ def fromrecords(recList, formats=None, names=None, titles=None, shape=None, if shape is not None and retval.shape != shape: retval.shape = shape - return retval.view(recarray) + res = retval.view(recarray) + res.dtype = sb.dtype((record, res.dtype)) + return res + def fromstring(datastring, formats, shape=None, names=None, titles=None, byteorder=None, aligned=0, offset=0): @@ -406,6 +409,8 @@ def array(obj, formats=None, names=None, titles=None, shape=None, shape=shape, byteorder=byteorder, aligned=aligned, offset=offset) elif isinstance(obj, sb.ndarray): - return obj.view(recarray) + res = obj.view(recarray) + if issubclass(res.dtype, nt.void): + res.dtype = sb.dtype((record, res.dtype)) else: raise ValueError("Unknown input type") diff --git a/numpy/core/src/multiarraymodule.c b/numpy/core/src/multiarraymodule.c index 1ba38eadf..295924fea 100644 --- a/numpy/core/src/multiarraymodule.c +++ b/numpy/core/src/multiarraymodule.c @@ -3930,12 +3930,12 @@ PyArray_DescrConverter(PyObject *obj, PyArray_Descr **at) } return PY_SUCCEED; } - else { + else goto fail; /*{ *at = _arraydescr_fromobj(obj); if (*at) return PY_SUCCEED; if (PyErr_Occurred()) return PY_FAIL; goto fail; - } + } */ if (PyErr_Occurred()) goto fail; /* |