summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/core/src/arrayobject.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c
index a1efd82e2..5f9ccdad1 100644
--- a/numpy/core/src/arrayobject.c
+++ b/numpy/core/src/arrayobject.c
@@ -5982,15 +5982,22 @@ array_descr_set(PyArrayObject *self, PyObject *arg)
PyErr_SetString(PyExc_TypeError, "invalid data-type for array");
return -1;
}
- if (newtype->type_num == PyArray_OBJECT || \
- self->descr->type_num == PyArray_OBJECT) {
- PyErr_SetString(PyExc_TypeError, \
- "Cannot change descriptor for object"\
+ if (newtype->hasobject || self->descr->hasobject) {
+ PyErr_SetString(PyExc_TypeError, \
+ "Cannot change data-type for object" \
"array.");
Py_DECREF(newtype);
return -1;
}
+ if (newtype->elsize == 0) {
+ PyErr_SetString(PyExc_TypeError,
+ "data-type must not be 0-sized");
+ Py_DECREF(newtype);
+ return -1;
+ }
+
+
if ((newtype->elsize != self->descr->elsize) && \
(self->nd == 0 || !PyArray_ISONESEGMENT(self) || \
newtype->subarray)) goto fail;