diff --git a/numpy/core/src/multiarray/common.c b/numpy/core/src/multiarray/common.c index 89d4c5f63ac7..1863410e2af2 100644 --- a/numpy/core/src/multiarray/common.c +++ b/numpy/core/src/multiarray/common.c @@ -286,7 +286,7 @@ _array_find_type(PyObject *op, PyArray_Descr *minitype, int max) * unless input was already a VOID */ if (outtype->type_num == PyArray_VOID && - minitype->type_num != PyArray_VOID) { + (minitype == NULL || minitype->type_num != PyArray_VOID)) { Py_DECREF(outtype); return PyArray_DescrFromType(PyArray_OBJECT); } diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index 6821fbe49e93..e7d44bde6d65 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -327,6 +327,10 @@ def test_from_string(self) : msg = 'String conversion for %s' % type assert_equal(array(nstr, dtype=type), result, err_msg=msg) + def test_void(self): + arr = np.array([np.void(0)], dtype='V') + assert_equal(arr.dtype.kind, 'V') + def test_non_sequence_sequence(self): """Should not segfault.