Issue 4597: Fix several cases in EvalFrameEx where an exception could be
"raised" without setting x, err, or why to let the eval loop know.
diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py
index b93bdbd..2d791a5 100644
--- a/Lib/test/test_file.py
+++ b/Lib/test/test_file.py
@@ -531,6 +531,20 @@
finally:
sys.stdout = save_stdout
+ def test_del_stdout_before_print(self):
+ # Issue 4597: 'print' with no argument wasn't reporting when
+ # sys.stdout was deleted.
+ save_stdout = sys.stdout
+ del sys.stdout
+ try:
+ print
+ except RuntimeError as e:
+ self.assertEquals(str(e), "lost sys.stdout")
+ else:
+ self.fail("Expected RuntimeError")
+ finally:
+ sys.stdout = save_stdout
+
def test_main():
# Historically, these tests have been sloppy about removing TESTFN.