Author: Armin Rigo <ar...@tunes.org>
Branch: 
Changeset: r76546:67167636348c
Date: 2015-03-24 20:53 +0100
http://bitbucket.org/pypy/pypy/changeset/67167636348c/

Log:    merge heads

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -16,3 +16,7 @@
 0000000000000000000000000000000000000000 release-2.5.1
 0000000000000000000000000000000000000000 release-2.5.1
 e3d046c43451403f5969580fc1c41d5df6c4082a release-2.5.1
+e3d046c43451403f5969580fc1c41d5df6c4082a release-2.5.1
+0000000000000000000000000000000000000000 release-2.5.1
+0000000000000000000000000000000000000000 release-2.5.1
+9c4588d731b7fe0b08669bd732c2b676cb0a8233 release-2.5.1
diff --git a/rpython/translator/c/test/test_exception.py 
b/rpython/translator/c/test/test_exception.py
--- a/rpython/translator/c/test/test_exception.py
+++ b/rpython/translator/c/test/test_exception.py
@@ -3,6 +3,7 @@
 from rpython.translator.c.test import test_typed
 from rpython.translator.c.test import test_backendoptimized
 from rpython.rtyper.lltypesystem import lltype
+from rpython.rlib.rarithmetic import ovfcheck
 
 getcompiled = test_typed.TestTypedTestCase().getcompiled
 getcompiledopt = test_backendoptimized.TestTypedOptimizedTestCase().getcompiled
@@ -28,9 +29,9 @@
             b = raise_(i) + 12
             c = raise_(i) + 13
             return a+b+c
-        except TestException: 
+        except TestException:
             return 7
-        except MyException: 
+        except MyException:
             return 123
         except:
             return 22
@@ -173,3 +174,41 @@
     f1 = getcompiledopt(fn, [int])
     res = f1(100)
     assert res == 42
+
+def test_getitem_custom_exception():
+    class MyError(Exception):
+        pass
+    class BadContainer(object):
+        def __getitem__(self, n):
+            raise MyError
+    def f():
+        d = BadContainer()
+        try:
+            return d[0]
+        except KeyError:
+            return 1
+    def g():
+        try:
+            return f()
+        except MyError:
+            return -1
+
+    assert g() == -1
+    compiled = getcompiled(g, [])
+    assert compiled() == -1
+
+def test_ovf_propagation():
+    def div(a, b):
+        try:
+            return ovfcheck(a//b)
+        except ZeroDivisionError:
+            raise
+    def f():
+        div(4, 2)
+        try:
+            return div(-sys.maxint-1, -1)
+        except OverflowError:
+            return 0
+    assert f() == 0
+    compiled = getcompiled(f, [])
+    assert compiled() == 0
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to