[pypy-svn] r10400 - in pypy/dist/pypy/translator: . test

pedronis at codespeak.net pedronis at codespeak.net
Thu Apr 7 15:45:45 CEST 2005


Author: pedronis
Date: Thu Apr  7 15:45:45 2005
New Revision: 10400

Modified:
   pypy/dist/pypy/translator/annrpython.py
   pypy/dist/pypy/translator/test/test_annrpython.py
Log:
re-instante the changes about implicit exceptions annotations from 10366, that were lost in the branching and merging



Modified: pypy/dist/pypy/translator/annrpython.py
==============================================================================
--- pypy/dist/pypy/translator/annrpython.py	(original)
+++ pypy/dist/pypy/translator/annrpython.py	Thu Apr  7 15:45:45 2005
@@ -372,7 +372,10 @@
             if isinstance(link.exitcase, (types.ClassType, type)) \
                    and issubclass(link.exitcase, Exception):
                 last_exception_object = annmodel.SomeObject()
-                last_exc_value_object = annmodel.SomeObject()
+                if link.exitcase is Exception:
+                    last_exc_value_object = annmodel.SomeObject()
+                else:
+                    last_exc_value_object = self.bookkeeper.valueoftype(link.exitcase)
                 last_exc_value_vars = []
                 in_except_block = True
                 last_exception_unknown = True

Modified: pypy/dist/pypy/translator/test/test_annrpython.py
==============================================================================
--- pypy/dist/pypy/translator/test/test_annrpython.py	(original)
+++ pypy/dist/pypy/translator/test/test_annrpython.py	Thu Apr  7 15:45:45 2005
@@ -613,6 +613,18 @@
         s = a.build_types(assert_, [])
         assert s.const is None
 
+    def test_implicit_exc(self):
+        def f(l):
+            try:
+                l[0]
+            except (KeyError, IndexError),e:
+                return e
+            return None
+
+        a = RPythonAnnotator()
+        s = a.build_types(f, [list])
+        assert s.knowntype is LookupError
+
     def test_overrides(self):
         import sys
         excs = []



More information about the Pypy-commit mailing list