Author: Matti Picus <matti.pi...@gmail.com> Branch: newmemoryview-app-level Changeset: r96158:2eee79cfc69a Date: 2019-02-24 23:15 +0200 http://bitbucket.org/pypy/pypy/changeset/2eee79cfc69a/
Log: add itemsize to the new view diff --git a/pypy/module/__pypy__/newmemoryview.py b/pypy/module/__pypy__/newmemoryview.py --- a/pypy/module/__pypy__/newmemoryview.py +++ b/pypy/module/__pypy__/newmemoryview.py @@ -59,14 +59,20 @@ "shape %s and strides %s exceed object size %d", shape, strides, nbytes) view = space.buffer_w(w_obj, 0) - return space.newmemoryview(FormatBufferViewND(view, format, ndim, shape, strides)) + return space.newmemoryview(FormatBufferViewND(view, itemsize, format, ndim, + shape, strides)) class FormatBufferViewND(BufferViewND): _immutable_ = True - _attrs_ = ['readonly', 'parent', 'ndim', 'shape', 'strides', 'format'] - def __init__(self, parent, format, ndim, shape, strides): + _attrs_ = ['readonly', 'parent', 'ndim', 'shape', 'strides', + 'format', 'itemsize'] + def __init__(self, parent, itemsize, format, ndim, shape, strides): BufferViewND.__init__(self, parent, ndim, shape, strides) - self.format = format + self.format = format + self.itemsize = itemsize def getformat(self): return self.format + + def getitemsize(self): + return self.itemsize diff --git a/pypy/module/__pypy__/test/test_newmemoryview.py b/pypy/module/__pypy__/test/test_newmemoryview.py --- a/pypy/module/__pypy__/test/test_newmemoryview.py +++ b/pypy/module/__pypy__/test/test_newmemoryview.py @@ -13,5 +13,4 @@ strides=(6, 2)) assert m.strides == (6, 2) assert m.format == 'T{<h:a}' - - + assert m.itemsize == 2 _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit