From: Christoph Groth Date: Wed, 19 Sep 2012 05:58:44 +0000 (+0200) Subject: make memoryviews work when strides is NULL X-Git-Tag: 0.18b1~226^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f73335a7a7b2f6dd5b898a8d9c7d92afe0f7bc6a;p=platform%2Fupstream%2Fpython-cython.git make memoryviews work when strides is NULL --- diff --git a/Cython/Utility/MemoryView_C.c b/Cython/Utility/MemoryView_C.c index 84e55da..c2524b0 100644 --- a/Cython/Utility/MemoryView_C.c +++ b/Cython/Utility/MemoryView_C.c @@ -207,12 +207,6 @@ static int __Pyx_ValidateAndInit_memviewslice( goto fail; } - if (!buf->strides) { - PyErr_SetString(PyExc_ValueError, - "buffer does not supply strides necessary for memoryview."); - goto fail; - } - for(i=0; istrides) { + for (i = 0; i < ndim; i++) { + memviewslice->strides[i] = buf->strides[i]; + } + } else { + Py_ssize_t stride = buf->itemsize; + for (i = ndim - 1; i >= 0; i--) { + memviewslice->strides[i] = stride; + stride *= buf->shape[i]; + } + } + for (i = 0; i < ndim; i++) { - memviewslice->strides[i] = buf->strides[i]; memviewslice->shape[i] = buf->shape[i]; if (buf->suboffsets) { memviewslice->suboffsets[i] = buf->suboffsets[i];