Author: Antonio Cuni <[email protected]>
Branch: py3k
Changeset: r57455:5f0417506726
Date: 2012-09-21 18:40 +0200
http://bitbucket.org/pypy/pypy/changeset/5f0417506726/
Log: a failing test and the corresponding fix. We want to make sure that
the exception state is cleared when the blocks are unrolled because
of a break
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -1315,7 +1315,7 @@
def handle(self, frame, unroller):
assert False # never called
- def cleanup(self, frame):
+ def cleanupstack(self, frame):
frame.dropvaluesuntil(self.valuestackdepth+1)
w_last_exception = frame.popvalue()
if not isinstance(w_last_exception, W_OperationError):
@@ -1323,7 +1323,7 @@
frame.space.str_w(w_last_exception))
raise BytecodeCorruption(msg)
frame.last_exception = w_last_exception.operr
- FrameBlock.cleanup(self, frame)
+ FrameBlock.cleanupstack(self, frame)
class ExceptBlock(FrameBlock):
diff --git a/pypy/interpreter/test/test_raise.py
b/pypy/interpreter/test/test_raise.py
--- a/pypy/interpreter/test/test_raise.py
+++ b/pypy/interpreter/test/test_raise.py
@@ -295,3 +295,12 @@
raise ValueError
except ValueError as e:
continue
+
+ def test_clear_last_exception_on_break(self):
+ import sys
+ for i in [0]:
+ try:
+ raise ValueError
+ except ValueError:
+ break
+ assert sys.exc_info() == (None, None, None)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit