[pypy-commit] pypy py3.6: make memroyview.setitem failure logic more like cpython

mattip pypy.commits at gmail.com
Sun Jun 23 01:40:03 EDT 2019


Author: Matti Picus <matti.picus at gmail.com>
Branch: py3.6
Changeset: r96844:4cc3da9ff28d
Date: 2019-06-23 08:39 +0300
http://bitbucket.org/pypy/pypy/changeset/4cc3da9ff28d/

Log:	make memroyview.setitem failure logic more like cpython

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
@@ -174,6 +174,9 @@
                     "cannot index %d-dimension view with %d-element tuple",
                     length, ndim)
 
+        elif is_multislice(space, w_index):
+            raise oefmt(space.w_NotImplementedError,
+                        "multi-dimensional slicing is not implemented")
         start = self._start_from_tuple(space, w_index)
         itemsize = self.getitemsize()
         val = self.view.bytes_from_value(space, w_obj)
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
@@ -299,7 +299,9 @@
         raises(TypeError, m.__setitem__, (2, 3), bytearray(b'12'))
         # slices in 2d memoryviews are not supported at all
         raises(TypeError, m.__getitem__, (slice(None), 3))
-        raises(NotImplementedError, m.__getitem__, (slice(None),))
+        raises(TypeError, m.__setitem__, (slice(None), 3), ord('a'))
+        raises(NotImplementedError, m.__getitem__, (slice(0,1,1), slice(0,1,2)))
+        raises(NotImplementedError, m.__setitem__, (slice(0,1,1), slice(0,1,2)), ord('a'))
 
 class AppTestCtypes(object):
     spaceconfig = dict(usemodules=['sys', '_rawffi'])


More information about the pypy-commit mailing list