8000 BUG: Make sure empty shapes are disallowed when data is specified · numpy/numpy@54b4dc7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 54b4dc7

Browse files
committed
BUG: Make sure empty shapes are disallowed when data is specified
1 parent bfceb53 commit 54b4dc7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

numpy/core/src/multiarray/ctors.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,6 +2074,11 @@ PyArray_FromInterface(PyObject *origin)
20742074
/* Case for data access through pointer */
20752075
else if (attr && PyTuple_Check(attr)) {
20762076
PyObject *dataptr;
2077+
if (n == 0) {
2078+
PyErr_SetString(PyExc_ValueError,
2079+
"__array_interface__ shape must be at least size 1");
2080+
goto fail;
2081+
}
20772082
if (PyTuple_GET_SIZE(attr) != 2) {
20782083
PyErr_SetString(PyExc_TypeError,
20792084
"__array_interface__ data must be a 2-tuple with "
@@ -2107,6 +2112,11 @@ PyArray_FromInterface(PyObject *origin)
21072112

21082113
/* Case for data access through buffer */
21092114
else {
2115+
if (n == 0) {
2116+
PyErr_SetString(PyExc_ValueError,
2117+
"__array_interface__ shape must be at least size 1");
2118+
goto fail;
2119+
}
21102120
if (attr && (attr != Py_None)) {
21112121
base = attr;
21122122
}

0 commit comments

Comments
 (0)
0