Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ff02df4

Browse files
committed
Undo size-0 iteration changes and fix possible core dump in PyArray_Return.
1 parent c1cdece commit ff02df4

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

THANKS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ Travis Vaught and Joe Cooper for administration of numpy.org web site and SVN
1414
Eric Firing for bugfixes.
1515
Arnd Baecker for 64-bit testing
1616
David Cooke for many code improvements including the auto-generated C-API
17+
Alexander Belopolsky (sasha) for Masked array bug-fixes and tests...

numpy/core/src/arrayobject.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,8 @@ PyArray_Return(PyArrayObject *mp)
916916
return NULL;
917917
}
918918

919+
if (!PyArray_Check(mp)) return (PyObject *)mp;
920+
919921
if (mp->nd == 0) {
920922
PyObject *ret;
921923
ret = PyArray_ToScalar(mp->data, mp);
@@ -6215,11 +6217,6 @@ PyArray_IterNew(PyObject *obj)
62156217
Py_INCREF(ao);
62166218
it->ao = ao;
62176219
it->size = PyArray_SIZE(ao);
6218-
if (it->size == 0) {
6219-
PyErr_SetString(PyExc_ValueError,
6220-
"Cannot iterate over a size-0 array");
6221-
return NULL;
6222-
}
62236220
it->nd_m1 = nd - 1;
62246221
it->factors[nd-1] = 1;
62256222
for (i=0; i < nd; i++) {

0 commit comments

Comments
 (0)