summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_support.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index 6f739af3fb..04a0ab8574 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -482,8 +482,10 @@ def captured_output(stream_name):
import StringIO
orig_stdout = getattr(sys, stream_name)
setattr(sys, stream_name, StringIO.StringIO())
- yield getattr(sys, stream_name)
- setattr(sys, stream_name, orig_stdout)
+ try:
+ yield getattr(sys, stream_name)
+ finally:
+ setattr(sys, stream_name, orig_stdout)
def captured_stdout():
return captured_output("stdout")