Author: Ronan Lamy <[email protected]>
Branch: py3.5
Changeset: r90058:de015dfe7aff
Date: 2017-02-11 19:41 +0000
http://bitbucket.org/pypy/pypy/changeset/de015dfe7aff/
Log: Test and partial fix for 0d memoryview
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
@@ -565,7 +565,7 @@
def _init_flags(self):
buf = self.buf
- ndim = buf.getndim()
+ ndim = self.getndim()
flags = 0
if ndim == 0:
flags |= MEMORYVIEW_SCALAR | MEMORYVIEW_C | MEMORYVIEW_FORTRAN
diff --git a/pypy/objspace/std/test/test_memoryobject.py
b/pypy/objspace/std/test/test_memoryobject.py
--- a/pypy/objspace/std/test/test_memoryobject.py
+++ b/pypy/objspace/std/test/test_memoryobject.py
@@ -27,6 +27,14 @@
assert len(w) == 2
exc = raises(TypeError, "memoryview('foobar')")
+ def test_0d(self):
+ v = memoryview(b'x').cast('B', ())
+ assert len(v) == 1
+ assert v.shape == ()
+ assert v.strides == ()
+ #assert v.tobytes() == b'x'
+ #assert v[()] == b'x'[0]
+
def test_rw(self):
data = bytearray(b'abcefg')
v = memoryview(data)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit