[pypy-commit] pypy py3.6: test, refactor to more closely match cpython

mattip pypy.commits at gmail.com
Mon Jun 24 05:18:32 EDT 2019


Author: Matti Picus <matti.picus at gmail.com>
Branch: py3.6
Changeset: r96850:da92ca675f66
Date: 2019-06-24 12:16 +0300
http://bitbucket.org/pypy/pypy/changeset/da92ca675f66/

Log:	test, refactor to more closely match 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
@@ -165,18 +165,19 @@
         view = self.view
         length = space.len_w(w_index)
         ndim = view.getndim()
-        if length < ndim:
+        if is_multislice(space, w_index):
             raise oefmt(space.w_NotImplementedError,
+                        "multi-dimensional slicing is not implemented")
+        elif length != ndim:
+            if length < ndim:
+                raise oefmt(space.w_NotImplementedError,
                         "sub-views are not implemented")
 
-        if length > ndim:
-            raise oefmt(space.w_TypeError, \
+            elif length > ndim:
+                raise oefmt(space.w_TypeError, \
                     "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
@@ -176,6 +176,7 @@
         assert m[0] == 0
         m[0] = 1
         assert m[0] == 1
+        raises(NotImplementedError, m.__setitem__, (slice(0,1,1), slice(0,1,2)), 0)
 
     def test_int_array_slice(self):
         import array


More information about the pypy-commit mailing list