Author: Ronan Lamy <[email protected]>
Branch: translation-cleanup
Changeset: r57459:24d010e8202f
Date: 2012-09-21 18:52 +0100
http://bitbucket.org/pypy/pypy/changeset/24d010e8202f/

Log:    Use FlowingError for non-constant excepts.

        * Add failing test (raises the wrong exception)

diff --git a/pypy/objspace/flow/objspace.py b/pypy/objspace/flow/objspace.py
--- a/pypy/objspace/flow/objspace.py
+++ b/pypy/objspace/flow/objspace.py
@@ -188,7 +188,7 @@
         try:
             check_class = self.unwrap(w_check_class)
         except UnwrapException:
-            raise Exception, "non-constant except guard"
+            raise FlowingError(self.frame, "Non-constant except guard.")
         if check_class in (NotImplementedError, AssertionError):
             raise FlowingError(self.frame,
                 "Catching %s is not valid in RPython" % check_class.__name__)
diff --git a/pypy/objspace/flow/test/test_objspace.py 
b/pypy/objspace/flow/test/test_objspace.py
--- a/pypy/objspace/flow/test/test_objspace.py
+++ b/pypy/objspace/flow/test/test_objspace.py
@@ -980,6 +980,16 @@
             self.codetest(f)
         assert 'div(5, 0)' in str(excinfo.value)
 
+    @py.test.mark.xfail
+    def test_nonconstant_except(self):
+        def f(exc_cls):
+            try:
+                raise AttributeError
+            except exc_cls:
+                pass
+        with py.test.raises(FlowingError):
+            self.codetest(f)
+
     def test__flowspace_rewrite_directly_as_(self):
         def g(x):
             pass
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to