[pypy-commit] pypy py3k: in python3, when we enter the finally: block because of an exception sys.exc_info() returns the current one, as it happens for except: blocks. In python2, the current exception was updated only inside the latters

antocuni noreply at buildbot.pypy.org
Mon Feb 13 18:27:17 CET 2012


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: py3k
Changeset: r52425:7ab281a6cae3
Date: 2012-02-13 13:46 +0100
http://bitbucket.org/pypy/pypy/changeset/7ab281a6cae3/

Log:	in python3, when we enter the finally: block because of an exception
	sys.exc_info() returns the current one, as it happens for except:
	blocks. In python2, the current exception was updated only inside
	the latters

diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -1298,9 +1298,16 @@
         # the block unrolling and the entering the finally: handler.
         # see comments in cleanup().
         self.cleanupstack(frame)
+        operationerr = None
+        if isinstance(unroller, SApplicationException):
+            operationerr = unroller.operr
+            if frame.space.full_exceptions:
+                operationerr.normalize_exception(frame.space)
         frame.pushvalue(frame.space.wrap(unroller))
         frame.pushvalue(frame.space.w_None)
         frame.pushvalue(frame.space.w_None)
+        if operationerr:
+            frame.last_exception = operationerr
         return self.handlerposition   # jump to the handler
 
 


More information about the pypy-commit mailing list