Skip to content

Commit

Permalink
Fix 0-length sequence error in numpy#882.
Browse files Browse the repository at this point in the history
  • Loading branch information
teoliphant committed Aug 29, 2008
1 parent ec588c7 commit adc0cc2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions numpy/core/src/multiarraymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2199,6 +2199,7 @@ PyArray_CanCoerceScalar(int thistype, int neededtype,
}
}

/* Raises error when len(op) == 0 */

/*NUMPY_API*/
static PyArrayObject **
Expand All @@ -2212,6 +2213,9 @@ PyArray_ConvertToCommonType(PyObject *op, int *retn)
NPY_SCALARKIND scalarkind=NPY_NOSCALAR, intypekind=NPY_NOSCALAR;

*retn = n = PySequence_Length(op);
if (n == 0) {
PyErr_SetString(PyExc_ValueError, "0-length sequence.");
}
if (PyErr_Occurred()) {*retn = 0; return NULL;}

mps = (PyArrayObject **)PyDataMem_NEW(n*sizeof(PyArrayObject *));
Expand Down

0 comments on commit adc0cc2

Please sign in to comment.