Author: Ronan Lamy <[email protected]>
Branch: framestate
Changeset: r75922:e6c7a78a35e5
Date: 2015-02-14 23:11 +0000
http://bitbucket.org/pypy/pypy/changeset/e6c7a78a35e5/
Log: handle interaction of return with finally: in analyze_signals()
diff --git a/rpython/flowspace/bytecode.py b/rpython/flowspace/bytecode.py
--- a/rpython/flowspace/bytecode.py
+++ b/rpython/flowspace/bytecode.py
@@ -618,8 +618,7 @@
block.operations.append(POP_BLOCK(offset=self.offset))
elif isinstance(context, FinallyBlock):
block.operations.append(POP_BLOCK(offset=self.offset))
- reader.splice_finally_handler(block, context)
- block = context.handler_end
+ block = reader.splice_finally_handler(block, context)
else: # LoopBlock
reader.blockstack.append(context)
block.set_exits([self.target])
@@ -645,9 +644,20 @@
class RETURN(NullaryOpcode):
num = name = 'RETURN'
arg = NO_ARG
+ def do_signals(self, reader):
+ block = reader.curr_block
+ assert block.operations[-1] is self
+ del block.operations[-1]
+ from rpython.flowspace.flowcontext import FinallyBlock
+ while reader.blockstack:
+ context = reader.blockstack.pop()
+ block.operations.append(POP_BLOCK(offset=self.offset))
+ if isinstance(context, FinallyBlock):
+ block = reader.splice_finally_handler(block, context)
+ block.operations.append(self)
+
def eval(self, ctx):
- from rpython.flowspace.flowcontext import Return
- raise Return()
+ ctx.do_return()
@bc_reader.register_opcode
class END_FINALLY(NullaryOpcode):
diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -1012,9 +1012,6 @@
class Return(FlowSignal):
"""Signals a 'return' statement. """
- def nomoreblocks(self, ctx):
- ctx.do_return()
-
@property
def args(self):
return []
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit