summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_support.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_support.py')
-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 f61e70a..431b66b 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -473,8 +473,10 @@ def captured_output(stream_name):
import io
orig_stdout = getattr(sys, stream_name)
setattr(sys, stream_name, io.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")