[pypy-commit] pypy py3k: fix test_with_reraise_2: when we pop a WithBlock, the exception must be considered already handled, and thus we don't want to restore it (which is different than FinallyBlock)

antocuni noreply at buildbot.pypy.org
Tue Feb 14 17:28:17 CET 2012


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: py3k
Changeset: r52465:84d8d3671171
Date: 2012-02-14 14:33 +0100
http://bitbucket.org/pypy/pypy/changeset/84d8d3671171/

Log:	fix test_with_reraise_2: when we pop a WithBlock, the exception must
	be considered already handled, and thus we don't want to restore it
	(which is different than FinallyBlock)

diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -1285,6 +1285,7 @@
     _immutable_ = True
     _opname = 'SETUP_FINALLY'
     handling_mask = -1     # handles every kind of SuspendedUnroller
+    restore_last_exception = True # set to False by WithBlock
 
     def cleanup(self, frame):
         # upon normal entry into the finally: part, the standard Python
@@ -1310,14 +1311,17 @@
         frame.pushvalue(frame.space.wrap(unroller))
         frame.pushvalue(frame.space.w_None)
         frame.pushvalue(frame.space.w_None)
-        if operationerr:
+        if operationerr and self.restore_last_exception:
             frame.last_exception = operationerr
         return self.handlerposition   # jump to the handler
 
+        
+
 
 class WithBlock(FinallyBlock):
 
     _immutable_ = True
+    restore_last_exception = False
 
     def really_handle(self, frame, unroller):
         if (frame.space.full_exceptions and


More information about the pypy-commit mailing list