diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-10-18 18:05:35 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-10-18 18:05:35 +0000 |
commit | 2e7c822ee511d36b36dc5df9b35bbacccfe366e5 (patch) | |
tree | 24741bb0214926209ede43635b864dbd6ff774d8 /numpy/core/src/arrayobject.c | |
parent | ed7b368d34b95f8391d5dbec35e6ae7e7f4b77dc (diff) | |
download | numpy-2e7c822ee511d36b36dc5df9b35bbacccfe366e5.tar.gz |
Fix Ticket #352
Diffstat (limited to 'numpy/core/src/arrayobject.c')
-rw-r--r-- | numpy/core/src/arrayobject.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index 30a791029..2c77622a4 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -4749,41 +4749,44 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) static PyObject * _check_axis(PyArrayObject *arr, int *axis, int flags) { - PyObject *temp; + PyObject *temp1, *temp2; int n = arr->nd; if ((*axis >= MAX_DIMS) || (n==0)) { if (n != 1) { - temp = PyArray_Ravel(arr,0); - if (temp) *axis = PyArray_NDIM(temp)-1; - else *axis = 0; + temp1 = PyArray_Ravel(arr,0); + if (temp1 == NULL) {*axis=0; return NULL;} + *axis = PyArray_NDIM(temp1)-1; } else { - temp = (PyObject *)arr; - Py_INCREF(temp); + temp1 = (PyObject *)arr; + Py_INCREF(temp1); *axis = 0; } - return temp; + if (!flags) return temp1; } else { - if (flags) { - temp = PyArray_CheckFromAny((PyObject *)arr, NULL, - 0, 0, flags, NULL); - if (temp == NULL) return NULL; - } - else { - Py_INCREF(arr); - temp = (PyObject *)arr; - } + temp1 = (PyObject *)arr; + Py_INCREF(temp1); } + if (flags) { + temp2 = PyArray_CheckFromAny((PyObject *)temp1, NULL, + 0, 0, flags, NULL); + Py_DECREF(temp1); + if (temp2 == NULL) return NULL; + } + else { + temp2 = (PyObject *)temp1; + } + n = PyArray_NDIM(temp2); if (*axis < 0) *axis += n; if ((*axis < 0) || (*axis >= n)) { PyErr_Format(PyExc_ValueError, "axis(=%d) out of bounds", *axis); - Py_DECREF(temp); + Py_DECREF(temp2); return NULL; } - return temp; + return temp2; } #include "arraymethods.c" |