diff options
Diffstat (limited to 'numpy/core/src/arrayobject.c')
-rw-r--r-- | numpy/core/src/arrayobject.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index 1cca1eebe..55abc36f0 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -4147,7 +4147,6 @@ array_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds) longlong offset=0; int fortran = 0; PyArrayObject *ret; - intp nb, off; buffer.ptr = NULL; /* Usually called with shape and type @@ -4185,36 +4184,35 @@ array_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds) } if (strides.ptr != NULL) { + intp nb, off; if (strides.len != dims.len) { PyErr_SetString(PyExc_ValueError, "strides, if given, must be " \ "the same length as shape"); goto fail; } - } - if (buffer.ptr == NULL) { - nb = 0; - off = 0; - } - else { - nb = buffer.len; - off = offset; - } - + if (buffer.ptr == NULL) { + nb = 0; + off = 0; + } + else { + nb = buffer.len; + off = offset; + } + - if (strides.ptr && \ - !PyArray_CheckStrides(itemsize, dims.len, - nb, off, - dims.ptr, strides.ptr)) { - PyErr_SetString(PyExc_ValueError, - "strides is incompatible " \ - "with shape of requested " \ - "array and size of buffer"); - goto fail; + if (!PyArray_CheckStrides(itemsize, dims.len, + nb, off, + dims.ptr, strides.ptr)) { + PyErr_SetString(PyExc_ValueError, + "strides is incompatible " \ + "with shape of requested " \ + "array and size of buffer"); + goto fail; + } } - - + if (buffer.ptr == NULL) { ret = (PyArrayObject *) \ PyArray_NewFromDescr(subtype, descr, |