]> granicus.if.org Git - python/commitdiff
Issue #8533: regrtest replaces also sys.stdout on Windows
authorVictor Stinner <victor.stinner@haypocalc.com>
Wed, 25 May 2011 00:01:55 +0000 (02:01 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Wed, 25 May 2011 00:01:55 +0000 (02:01 +0200)
Replace sys.stdout to use backslashreplace. Use '\n' newline on all operating
systems.

Lib/test/regrtest.py

index 04e87e3d45393500f3541d1ccb5ab2823e683208..b5e5127059054530f4fed3fb1e4d04ed16c23eea 100755 (executable)
@@ -794,17 +794,14 @@ def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS):
 def replace_stdout():
     """Set stdout encoder error handler to backslashreplace (as stderr error
     handler) to avoid UnicodeEncodeError when printing a traceback"""
-    if os.name == "nt":
-        # Replace sys.stdout breaks the stdout newlines on Windows: issue #8533
-        return
-
     import atexit
 
     stdout = sys.stdout
     sys.stdout = open(stdout.fileno(), 'w',
         encoding=stdout.encoding,
         errors="backslashreplace",
-        closefd=False)
+        closefd=False,
+        newline='\n')
 
     def restore_stdout():
         sys.stdout.close()