Issue #8533: regrtest replaces also sys.stdout on Windows
Replace sys.stdout to use backslashreplace. Use '\n' newline on all operating systems.
This commit is contained in:
parent
6daa33c8ac
commit
be6210363e
|
@ -794,17 +794,14 @@ def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS):
|
||||||
def replace_stdout():
|
def replace_stdout():
|
||||||
"""Set stdout encoder error handler to backslashreplace (as stderr error
|
"""Set stdout encoder error handler to backslashreplace (as stderr error
|
||||||
handler) to avoid UnicodeEncodeError when printing a traceback"""
|
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
|
import atexit
|
||||||
|
|
||||||
stdout = sys.stdout
|
stdout = sys.stdout
|
||||||
sys.stdout = open(stdout.fileno(), 'w',
|
sys.stdout = open(stdout.fileno(), 'w',
|
||||||
encoding=stdout.encoding,
|
encoding=stdout.encoding,
|
||||||
errors="backslashreplace",
|
errors="backslashreplace",
|
||||||
closefd=False)
|
closefd=False,
|
||||||
|
newline='\n')
|
||||||
|
|
||||||
def restore_stdout():
|
def restore_stdout():
|
||||||
sys.stdout.close()
|
sys.stdout.close()
|
||||||
|
|
Loading…
Reference in New Issue