Commits

Manuel Jacob committed 9467784

SubBuffers need a specific format and itemsize.

  • Participants
  • Parent commits 3708c6a
  • Branches py3k-memoryview

Comments (0)

Files changed (2)

File pypy/interpreter/buffer.py

         raise OperationError(space.w_ValueError,
                              space.wrap("size must be zero or positive"))
     if isinstance(buffer, RWBuffer):
-        buffer = RWSubBuffer(buffer, offset, size)
+        buffer = RWSubBuffer(buffer, offset, size, 'B', 1)
     else:
-        buffer = SubBuffer(buffer, offset, size)
+        buffer = SubBuffer(buffer, offset, size, 'B', 1)
     return space.wrap(buffer)
 
 
 class SubBufferMixin(object):
     _mixin_ = True
 
-    def __init__(self, buffer, offset, size):
+    def __init__(self, buffer, offset, size, format, itemsize):
         self.buffer = buffer
         self.offset = offset
         self.size = size
-        self.format = 'B'
-        self.itemsize = 1
+        self.format = format
+        self.itemsize = itemsize
 
     def getlength(self):
         at_most = self.buffer.getlength() - self.offset

File pypy/module/__builtin__/interp_memoryview.py

             size = 0
         buf = self.buf
         if isinstance(buf, buffer.RWBuffer):
-            buf = buffer.RWSubBuffer(buf, start, size)
+            buf = buffer.RWSubBuffer(buf, start, size, buf.format, buf.itemsize)
         else:
-            buf = buffer.SubBuffer(buf, start, size)
+            buf = buffer.SubBuffer(buf, start, size, buf.format, buf.itemsize)
         return W_MemoryView(buf)
 
     def descr_buffer(self, space):