Author: Ronan Lamy <ronan.l...@gmail.com>
Branch: exc-later
Changeset: r76506:7da3860806b3
Date: 2015-03-23 03:00 +0000
http://bitbucket.org/pypy/pypy/changeset/7da3860806b3/

Log:    add a failing test

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
@@ -28,9 +28,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 +173,25 @@
     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
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to