summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-03-03 16:45:16 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-03-03 16:45:16 +0000
commit07a9750e934ad45f086b73b9f9f114ea4b2fcdd1 (patch)
tree08cf702655d15eb3e0d1df765de109b2ac669c9b
parent7db985eaaac53558b3b2af322375f237ca4fe457 (diff)
downloadnumpy-07a9750e934ad45f086b73b9f9f114ea4b2fcdd1.tar.gz
Fix an issue with string/unicode arrays created from scalars.
-rw-r--r--numpy/core/numerictypes.py2
-rw-r--r--numpy/core/src/arrayobject.c6
2 files changed, 3 insertions, 5 deletions
diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py
index aeb2c5225..75cd8de45 100644
--- a/numpy/core/numerictypes.py
+++ b/numpy/core/numerictypes.py
@@ -368,7 +368,7 @@ for key in _sctype2char_dict.keys():
cast[key] = lambda x, k=key : array(x, copy=False).astype(k)
-_unicodesize = array('u','U').itemsize
+_unicodesize = array('u','U1').itemsize
# Create the typestring lookup dictionary
_typestr = _typedict()
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c
index b004ca6a4..739dc69c7 100644
--- a/numpy/core/src/arrayobject.c
+++ b/numpy/core/src/arrayobject.c
@@ -5431,10 +5431,8 @@ Array_FromScalar(PyObject *op, PyArray_Descr *typecode)
if (type == PyArray_UNICODE) itemsize *= 4;
}
- ret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, typecode,
- 0, NULL,
- NULL, NULL, 0, NULL);
-
+ ret = (PyArrayObject *)PyArray_New(&PyArray_Type, 0, NULL, type,
+ NULL, NULL, itemsize, 0, NULL);
if (ret == NULL) return NULL;
if (ret->nd > 0) {
PyErr_SetString(PyExc_ValueError,