Author: Anton Gulenko <anton.gule...@googlemail.com> Branch: storage-context-state Changeset: r924:f5b3945a1fdc Date: 2014-07-19 13:48 +0200 http://bitbucket.org/pypy/lang-smalltalk/changeset/f5b3945a1fdc/
Log: Fixed ensure: mechanism. Fixed test. diff --git a/spyvm/interpreter.py b/spyvm/interpreter.py --- a/spyvm/interpreter.py +++ b/spyvm/interpreter.py @@ -819,10 +819,8 @@ self.push(self.gettemp(0)) # push the first argument try: self.bytecodePrimValue(interp, 0) - except Return, nlr: - assert nlr.s_target_context or nlr.is_local - if self is not nlr.s_target_context and not nlr.is_local: - raise nlr + except LocalReturn, ret: + pass # Local return value of ensure: block is ignored finally: self.mark_returned() diff --git a/spyvm/test/test_interpreter.py b/spyvm/test/test_interpreter.py --- a/spyvm/test/test_interpreter.py +++ b/spyvm/test/test_interpreter.py @@ -979,7 +979,7 @@ test) def test_frame_dirty_if_active(): - bytes = reduce(operator.add, map(chr, [0x84, 0xc0, 0x00])) + returnReceiverBytecode + bytes = reduce(operator.add, map(chr, [0x84, 0xc0, 0x00])) w_frame, s_frame = new_frame(bytes) s_frame.store_w_receiver(w_frame) s_frame.push(w_frame) @@ -988,7 +988,7 @@ assert s_frame.state is shadow.DirtyContext def test_frame_not_dirty_if_inactive(): - bytes = reduce(operator.add, map(chr, [0x84, 0xc0, 0x00])) + returnReceiverBytecode + bytes = reduce(operator.add, map(chr, [0x84, 0xc0, 0x00])) w_frame, s_frame = new_frame(bytes) w_other_frame, s_other_frame = new_frame("") s_frame.store_w_receiver(w_other_frame) @@ -998,12 +998,14 @@ assert s_frame.state is shadow.ActiveContext assert s_other_frame.state is shadow.InactiveContext -def test_raise_SenderManipulation_on_dirty_frame(): - w_frame, s_frame = new_frame(returnReceiverBytecode) - s_frame.state = shadow.DirtyContext - def run_frame(): - #import pdb; pdb.set_trace() - interp._loop = True +def test_raise_NonVirtualReturn_on_dirty_frame(): + bytes = reduce(operator.add, map(chr, [0x84, 0xc0, 0x00])) + returnTopFromMethodBytecode + w_frame, s_frame = new_frame(bytes) + s_frame.store_w_receiver(w_frame) + s_frame.push(w_frame) + + interp._loop = True + def do_test(): interp.stack_frame(s_frame, None) - py.test.raises(interpreter.SenderChainManipulation, run_frame) + py.test.raises(interpreter.NonVirtualReturn, do_test) \ No newline at end of file _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit