Author: Richard Plangger <[email protected]>
Branch: py3.5-memoryview
Changeset: r86747:ff89f145aa44
Date: 2016-08-30 17:56 +0200
http://bitbucket.org/pypy/pypy/changeset/ff89f145aa44/

Log:    apply small fixes. passing all memory view tests

diff --git a/pypy/objspace/std/memoryobject.py 
b/pypy/objspace/std/memoryobject.py
--- a/pypy/objspace/std/memoryobject.py
+++ b/pypy/objspace/std/memoryobject.py
@@ -269,9 +269,13 @@
                 fmtiter = UnpackFormatIterator(space, buf)
                 fmtiter.interpret(self.format)
                 return fmtiter.result_w[0]
-        elif step >= 1:
-            buf = SubBuffer(self.buf, start, size)
-            mv = W_MemoryView.copy(self, buf)
+        elif step == 1:
+            mv = W_MemoryView.copy(self)
+            mv.slice(start, stop, step, size)
+            mv._init_flags()
+            return mv
+        else:
+            mv = W_MemoryView.copy(self)
             mv.slice(start, stop, step, size)
             mv.length = mv.bytecount_from_shape()
             mv._init_flags()
@@ -279,13 +283,13 @@
 
     def slice(self, start, stop, step, size):
         # modifies the buffer, shape and stride to allow step to be > 1
-        # NOTE that start & stop are already byte offsets
+        # NOTE that start, stop & size are already byte offsets/count
         # TODO subbuffer
         strides = self.getstrides()[:]
         shape = self.getshape()[:]
         itemsize = self.getitemsize()
         dim = 0
-        self.buf = SubBuffer(self.buf, strides[dim] * (start//itemsize), size 
* itemsize)
+        self.buf = SubBuffer(self.buf, strides[dim] * (start//itemsize), 
size*step)
         shape[dim] = size
         strides[dim] = strides[dim] * step
         self.strides = strides
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to