diff options
author | Travis Oliphant <oliphant@enthought.com> | 2008-08-29 12:47:34 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2008-08-29 12:47:34 +0000 |
commit | adc0cc2463de413a03e4b038771ea9eef3c09125 (patch) | |
tree | 1c568f55d197a926bcac38783963dd9669613dcc /numpy/core | |
parent | ec588c7896b70bf07a1b2ee00977ef4bc177729e (diff) | |
download | numpy-adc0cc2463de413a03e4b038771ea9eef3c09125.tar.gz |
Fix 0-length sequence error in #882.
Diffstat (limited to 'numpy/core')
-rw-r--r-- | numpy/core/src/multiarraymodule.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/numpy/core/src/multiarraymodule.c b/numpy/core/src/multiarraymodule.c index 8fcc3c96e..022d6f1c4 100644 --- a/numpy/core/src/multiarraymodule.c +++ b/numpy/core/src/multiarraymodule.c @@ -2199,6 +2199,7 @@ PyArray_CanCoerceScalar(int thistype, int neededtype, } } +/* Raises error when len(op) == 0 */ /*NUMPY_API*/ static PyArrayObject ** @@ -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 *)); |