summaryrefslogtreecommitdiff
path: root/numpy/core/src/arrayobject.c
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-10-18 18:15:26 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-10-18 18:15:26 +0000
commitb022765aa487070866663b1707e4a2a0d8ead2e8 (patch)
tree88d49b24f895ea4e658bcd9566d1861854f6df12 /numpy/core/src/arrayobject.c
parent2e7c822ee511d36b36dc5df9b35bbacccfe366e5 (diff)
downloadnumpy-b022765aa487070866663b1707e4a2a0d8ead2e8.tar.gz
Fix-up so that if on creation, a string or unicode data-type has an empty elsize it is reset to the size of one character.
Diffstat (limited to 'numpy/core/src/arrayobject.c')
-rw-r--r--numpy/core/src/arrayobject.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c
index 2c77622a4..b8f3bbad2 100644
--- a/numpy/core/src/arrayobject.c
+++ b/numpy/core/src/arrayobject.c
@@ -5255,9 +5255,15 @@ PyArray_NewFromDescr(PyTypeObject *subtype, PyArray_Descr *descr, int nd,
size = 1;
sd = (size_t) descr->elsize;
if (sd == 0) {
- PyErr_SetString(PyExc_ValueError, "Empty data-type");
- Py_DECREF(descr);
- return NULL;
+ if (!PyDataType_ISSTRING(descr)) {
+ PyErr_SetString(PyExc_ValueError, "Empty data-type");
+ Py_DECREF(descr);
+ return NULL;
+ }
+ PyArray_DESCR_REPLACE(descr);
+ if (descr->type_num == NPY_STRING) descr->elsize = 1;
+ else descr->elsize = sizeof(PyArray_UCS4);
+ sd = (size_t) descr->elsize;
}
largest = MAX_INTP / sd;
for (i=0;i<nd;i++) {