[Numpy-svn] r4823 - trunk/numpy/core/src
numpy-svn at scipy.org
numpy-svn at scipy.org
Tue Feb 26 16:17:18 EST 2008
Author: oliphant
Date: 2008-02-26 15:17:13 -0600 (Tue, 26 Feb 2008)
New Revision: 4823
Modified:
trunk/numpy/core/src/arrayobject.c
Log:
Make sure that mp is an array before testing for 0-d ness.
Modified: trunk/numpy/core/src/arrayobject.c
===================================================================
--- trunk/numpy/core/src/arrayobject.c 2008-02-25 22:51:21 UTC (rev 4822)
+++ trunk/numpy/core/src/arrayobject.c 2008-02-26 21:17:13 UTC (rev 4823)
@@ -3032,6 +3032,11 @@
mp = (PyArrayObject *)array_subscript(self, op);
+ /* mp could be a scalar if op is not an Int, Scalar, Long or other Index
+ object and still convertable to an integer (so that the code goes to
+ array_subscript_simple). So, this cast is a bit dangerous..
+ */
+
/* The following is just a copy of PyArray_Return with an
additional logic in the nd == 0 case.
*/
@@ -3043,14 +3048,15 @@
return NULL;
}
- if (mp->nd == 0) {
+ if (PyArray_Check(mp) && mp->nd == 0) {
Bool noellipses = TRUE;
if ((op == Py_Ellipsis) || PyString_Check(op) || PyUnicode_Check(op))
noellipses = FALSE;
else if (PyBool_Check(op) || PyArray_IsScalar(op, Bool) ||
(PyArray_Check(op) && (PyArray_DIMS(op)==0) &&
- PyArray_ISBOOL(op)))
- noellipses = FALSE;
+ PyArray_ISBOOL(op))) {
+ noellipses = FALSE;
+ }
else if (PySequence_Check(op)) {
int n, i;
PyObject *temp;
More information about the Numpy-svn
mailing list