diff options
Diffstat (limited to 'numpy/core/src/arrayobject.c')
-rw-r--r-- | numpy/core/src/arrayobject.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index 65443ecd9..e7aad394a 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -5431,8 +5431,14 @@ Array_FromScalar(PyObject *op, PyArray_Descr *typecode) if (type == PyArray_UNICODE) itemsize *= 4; } - ret = (PyArrayObject *)PyArray_New(&PyArray_Type, 0, NULL, type, - NULL, NULL, itemsize, 0, NULL); + if (itemsize != typecode->elsize) { + PyArray_DESCR_REPLACE(typecode); + typecode->elsize = itemsize; + } + + ret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, typecode, + 0, NULL, + NULL, NULL, 0, NULL); if (ret == NULL) return NULL; if (ret->nd > 0) { PyErr_SetString(PyExc_ValueError, |