[pypy-svn] r52550 - in pypy/dist/pypy: objspace/flow translator/test

arigo at codespeak.net arigo at codespeak.net
Sat Mar 15 10:04:55 CET 2008


Author: arigo
Date: Sat Mar 15 10:04:53 2008
New Revision: 52550

Modified:
   pypy/dist/pypy/objspace/flow/objspace.py
   pypy/dist/pypy/translator/test/test_geninterp.py
Log:
experimental: get rid of the AttributeError and TypeError exceptions
produced by the flow object space (unless, of course, we're geninterp;
add a test for this case)


Modified: pypy/dist/pypy/objspace/flow/objspace.py
==============================================================================
--- pypy/dist/pypy/objspace/flow/objspace.py	(original)
+++ pypy/dist/pypy/objspace/flow/objspace.py	Sat Mar 15 10:04:53 2008
@@ -449,6 +449,14 @@
         return w_res
 
     def handle_implicit_exceptions(self, exceptions):
+        if not exceptions:
+            return
+        if not self.config.translation.builtins_can_raise_exceptions:
+            # clean up 'exceptions' by removing the non-RPythonic exceptions
+            # which might be listed for geninterp.
+            exceptions = [exc for exc in exceptions
+                              if exc is not TypeError and
+                                 exc is not AttributeError]
         if exceptions:
             # catch possible exceptions implicitly.  If the OperationError
             # below is not caught in the same function, it will produce an

Modified: pypy/dist/pypy/translator/test/test_geninterp.py
==============================================================================
--- pypy/dist/pypy/translator/test/test_geninterp.py	(original)
+++ pypy/dist/pypy/translator/test/test_geninterp.py	Sat Mar 15 10:04:53 2008
@@ -284,3 +284,7 @@
         result = fn("abc")
         assert result == u"abc" and type(result) is unicode
 
+    def test_attributeerror(self):
+        fn = self.build_interpfunc(snippet.t_attrerror)
+        result = fn(42)
+        assert result == 567



More information about the Pypy-commit mailing list