[pypy-commit] pypy translation-cleanup: Copy end_finally() into FSFrame

rlamy noreply at buildbot.pypy.org
Mon Sep 24 22:35:53 CEST 2012


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: translation-cleanup
Changeset: r57520:a8bc9d7d6b42
Date: 2012-09-24 03:39 +0100
http://bitbucket.org/pypy/pypy/changeset/a8bc9d7d6b42/

Log:	Copy end_finally() into FSFrame

diff --git a/pypy/objspace/flow/flowcontext.py b/pypy/objspace/flow/flowcontext.py
--- a/pypy/objspace/flow/flowcontext.py
+++ b/pypy/objspace/flow/flowcontext.py
@@ -517,7 +517,27 @@
             return next_instr    # now inside a 'finally' block
 
     def END_FINALLY(self, oparg, next_instr):
-        unroller = self.end_finally()
+        # unlike CPython, there are two statically distinct cases: the
+        # END_FINALLY might be closing an 'except' block or a 'finally'
+        # block.  In the first case, the stack contains three items:
+        #   [exception type we are now handling]
+        #   [exception value we are now handling]
+        #   [wrapped SApplicationException]
+        # In the case of a finally: block, the stack contains only one
+        # item (unlike CPython which can have 1, 2 or 3 items):
+        #   [wrapped subclass of SuspendedUnroller]
+        w_top = self.popvalue()
+        # the following logic is a mess for the flow objspace,
+        # so we hide it specially in the space :-/
+        if self.space._check_constant_interp_w_or_w_None(SuspendedUnroller, w_top):
+            # case of a finally: block
+            unroller = self.space.interpclass_w(w_top)
+        else:
+            # case of an except: block.  We popped the exception type
+            self.popvalue()        #     Now we pop the exception value
+            unroller = self.space.interpclass_w(self.popvalue())
+            assert unroller is not None
+
         if isinstance(unroller, SuspendedUnroller):
             # go on unrolling the stack
             block = self.unrollstack(unroller.kind)


More information about the pypy-commit mailing list