[pypy-commit] pypy py3k: fix test_context_with_suppressed, always reset the last exception after
pjenvey
pypy.commits at gmail.com
Sat May 21 18:05:07 EDT 2016
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r84555:7737b9ffdd0b
Date: 2016-05-21 15:01 -0700
http://bitbucket.org/pypy/pypy/changeset/7737b9ffdd0b/
Log: fix test_context_with_suppressed, always reset the last exception
after __exit__, even if it raises
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -1138,12 +1138,14 @@
old_last_exception = self.last_exception
self.last_exception = operr
w_traceback = self.space.wrap(operr.get_traceback())
- w_suppress = self.call_contextmanager_exit_function(
- w_exitfunc,
- operr.w_type,
- operr.get_w_value(self.space),
- w_traceback)
- self.last_exception = old_last_exception
+ try:
+ w_suppress = self.call_contextmanager_exit_function(
+ w_exitfunc,
+ operr.w_type,
+ operr.get_w_value(self.space),
+ w_traceback)
+ finally:
+ self.last_exception = old_last_exception
if self.space.is_true(w_suppress):
# __exit__() returned True -> Swallow the exception.
self.settopvalue(self.space.w_None)
More information about the pypy-commit
mailing list