[pypy-commit] pypy exc-later: take builtins_exceptions into account before adding the Exception case

rlamy noreply at buildbot.pypy.org
Thu Mar 19 17:04:54 CET 2015


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: exc-later
Changeset: r76474:2de33decd42a
Date: 2015-03-18 21:26 +0000
http://bitbucket.org/pypy/pypy/changeset/2de33decd42a/

Log:	take builtins_exceptions into account before adding the Exception
	case

diff --git a/rpython/flowspace/test/test_objspace.py b/rpython/flowspace/test/test_objspace.py
--- a/rpython/flowspace/test/test_objspace.py
+++ b/rpython/flowspace/test/test_objspace.py
@@ -336,7 +336,7 @@
         simplify_graph(x)
         self.show(x)
         exc_cases = [exit.exitcase for exit in x.startblock.exits]
-        assert exc_cases == [None, OSError]
+        assert exc_cases == [None, OSError, Exception]
 
     #__________________________________________________________
     def reraiseAnythingDicCase(dic):
@@ -501,7 +501,7 @@
         simplify_graph(graph)
         assert self.all_operations(graph) == {'simple_call': 1}
         exc_cases = [exit.exitcase for exit in graph.startblock.exits]
-        assert exc_cases == [None, IndexError, OSError]
+        assert exc_cases == [None, IndexError, OSError, Exception]
 
     #__________________________________________________________
     def dellocal():
diff --git a/rpython/translator/simplify.py b/rpython/translator/simplify.py
--- a/rpython/translator/simplify.py
+++ b/rpython/translator/simplify.py
@@ -342,7 +342,15 @@
                 if not exits:
                     block.exitswitch = None
                 block.recloseblock(block.exits[0], *exits)
-
+            else:
+                if block.exits[-1].exitcase is not Exception:
+                    v_etype = Variable('last_exception')
+                    v_exc = Variable('last_exc_value')
+                    exit = Link([v_etype, v_exc], graph.exceptblock, Exception)
+                    exit.extravars(v_etype, v_exc)
+                    exits = list(block.exits)
+                    exits.append(exit)
+                    block.recloseblock(*exits)
 
 
 def remove_assertion_errors(graph):
@@ -363,15 +371,6 @@
             if block.canraise:
                 if exit.exitcase is None:
                     break
-                elif (exit.exitcase is Exception and
-                      block.raising_op.opname
-                        in ('simple_call', 'call_args')):
-                    v_etype = Variable('last_exception')
-                    v_exc = Variable('last_exc_value')
-                    exit.args = [v_etype, v_exc]
-                    exit.last_exception = v_etype
-                    exit.last_exc_value = v_exc
-                    continue
                 if len(block.exits) == 2:
                     # removing the last non-exceptional exit
                     block.exitswitch = None


More information about the pypy-commit mailing list