Author: Ronan Lamy <[email protected]>
Branch: py3.7
Changeset: r97355:24c3e187ed91
Date: 2019-08-31 22:11 +0100
http://bitbucket.org/pypy/pypy/changeset/24c3e187ed91/

Log:    hg merge py3.6

diff --git a/pypy/module/array/interp_array.py 
b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -1222,12 +1222,12 @@
             w_a = mytype.w_class(self.space)
             w_a.setlen(size, overallocate=False)
             assert step != 0
-            j = 0
             buf = w_a.get_buffer()
             srcbuf = self.get_buffer()
-            for i in range(start, stop, step):
+            i = start
+            for j in range(size):
                 buf[j] = srcbuf[i]
-                j += 1
+                i += step
             keepalive_until_here(self)
             keepalive_until_here(w_a)
             return w_a
@@ -1259,12 +1259,12 @@
                     self.setlen(0)
                     self.fromsequence(w_lst)
             else:
-                j = 0
                 buf = self.get_buffer()
                 srcbuf = w_item.get_buffer()
-                for i in range(start, stop, step):
+                i = start
+                for j in range(size):
                     buf[i] = srcbuf[j]
-                    j += 1
+                    i += step
                 keepalive_until_here(w_item)
                 keepalive_until_here(self)
 
diff --git a/pypy/module/array/test/test_array.py 
b/pypy/module/array/test/test_array.py
--- a/pypy/module/array/test/test_array.py
+++ b/pypy/module/array/test/test_array.py
@@ -400,6 +400,17 @@
                         except ValueError:
                             assert not ok
 
+    def test_getslice_large_step(self):
+        import sys
+        a = self.array('b', [1, 2, 3])
+        assert list(a[1::sys.maxsize]) == [2]
+
+    def test_setslice_large_step(self):
+        import sys
+        a = self.array('b', [1, 2, 3])
+        a[1::sys.maxsize] = self.array('b', [42])
+        assert a.tolist() == [1, 42, 3]
+
     def test_toxxx(self):
         a = self.array('i', [1, 2, 3])
         l = a.tolist()
diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -566,11 +566,12 @@
         if not isinstance(w_check_class, Constant):
             raise FlowingError("Non-constant except guard.")
         check_class = w_check_class.value
-        if check_class in (NotImplementedError, AssertionError):
-            raise FlowingError(
-                "Catching %s is not valid in RPython" % check_class.__name__)
         if not isinstance(check_class, tuple):
             # the simple case
+            if issubclass(check_class, (NotImplementedError, AssertionError)):
+                raise FlowingError(
+                    "Catching NotImplementedError, AssertionError, or a "
+                    "subclass is not valid in RPython (%r)" % (check_class,))
             return self.guessbool(op.issubtype(w_exc_type, 
w_check_class).eval(self))
         # special case for StackOverflow (see rlib/rstackovf.py)
         if check_class == rstackovf.StackOverflow:
diff --git a/rpython/flowspace/test/test_objspace.py 
b/rpython/flowspace/test/test_objspace.py
--- a/rpython/flowspace/test/test_objspace.py
+++ b/rpython/flowspace/test/test_objspace.py
@@ -1135,6 +1135,23 @@
                 pass
         py.test.raises(FlowingError, "self.codetest(f)")
 
+    def test_cannot_catch_special_exceptions_2(self):
+        class MyNIE(NotImplementedError):
+            pass
+        def f():
+            try:
+                f()
+            except MyNIE:
+                pass
+        py.test.raises(FlowingError, "self.codetest(f)")
+        #
+        def f():
+            try:
+                f()
+            except (ValueError, MyNIE):
+                pass
+        py.test.raises(FlowingError, "self.codetest(f)")
+
     def test_locals_dict(self):
         def f():
             x = 5
diff --git a/rpython/rlib/rawstorage.py b/rpython/rlib/rawstorage.py
--- a/rpython/rlib/rawstorage.py
+++ b/rpython/rlib/rawstorage.py
@@ -55,7 +55,7 @@
     misaligned_is_fine = False
 
 
-class AlignmentError(NotImplementedError):
+class AlignmentError(Exception):
     "Means that raw_storage_{get,set}item was used on unaligned memory"
 
 # Tweak?  It seems a reasonable value for any system out there: requiring
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to