diff options
-rw-r--r-- | numpy/core/src/multiarray/array_coercion.c | 10 | ||||
-rw-r--r-- | numpy/core/src/multiarray/ctors.c | 4 |
2 files changed, 11 insertions, 3 deletions
diff --git a/numpy/core/src/multiarray/array_coercion.c b/numpy/core/src/multiarray/array_coercion.c index 13d6682f7..f77a4a898 100644 --- a/numpy/core/src/multiarray/array_coercion.c +++ b/numpy/core/src/multiarray/array_coercion.c @@ -1395,8 +1395,13 @@ PyArray_DiscoverDTypeAndShape( * @return 1 if this is not a concrete dtype instance 0 otherwise */ static int -descr_is_legacy_parametric_instance(PyArray_Descr *descr) +descr_is_legacy_parametric_instance(PyArray_Descr *descr, + PyArray_DTypeMeta *DType) { + if (!NPY_DT_is_legacy(DType)) { + return 0; + } + if (PyDataType_ISUNSIZED(descr)) { return 1; } @@ -1440,7 +1445,8 @@ PyArray_ExtractDTypeAndDescriptor(PyObject *dtype, (PyTypeObject *)&PyArrayDTypeMeta_Type)) { *out_DType = NPY_DTYPE(dtype); Py_INCREF(*out_DType); - if (!descr_is_legacy_parametric_instance((PyArray_Descr *)dtype)) { + if (!descr_is_legacy_parametric_instance((PyArray_Descr *)dtype, + *out_DType)) { *out_descr = (PyArray_Descr *)dtype; Py_INCREF(*out_descr); } diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c index 4f0bc7337..280cdb0c7 100644 --- a/numpy/core/src/multiarray/ctors.c +++ b/numpy/core/src/multiarray/ctors.c @@ -20,6 +20,7 @@ #include "common.h" #include "ctors.h" #include "convert_datatype.h" +#include "dtypemeta.h" #include "shape.h" #include "npy_buffer.h" #include "lowlevel_strided_loops.h" @@ -664,7 +665,8 @@ PyArray_NewFromDescr_int( /* Check datatype element size */ nbytes = descr->elsize; if (PyDataType_ISUNSIZED(descr)) { - if (!PyDataType_ISFLEXIBLE(descr)) { + if (!PyDataType_ISFLEXIBLE(descr) && + NPY_DT_is_legacy(NPY_DTYPE(descr))) { PyErr_SetString(PyExc_TypeError, "Empty data-type"); Py_DECREF(descr); return NULL; |