STINNER Victor added the comment:

> On Windows, stdin, stdout and stderr are creates using TextIOWrapper(..., 
> newline=None).
> In this case, TextIOWrapper._writenl is os.linesep and so '\r\n'.

Oh, I was wrong: stdin is created with newline=None, but stdout and stderr are 
created with newline="\n" and so "\n" is not translated to "\r\n".

I checked in Python 2.7: print("abc") and sys.stdout.write("abc\n") writes 
b"abc\r\n" into the output file (when the output is redirected), but 
sys.stdout.write("abc\r\n") writes b"abc\r\r\n". Python 3.3 should do the same: 
\r\n is preferred on Windows (ex: notepad doesn't support UNIX line ending, \n).

Attached patch changes line ending for stdout and stderr on Windows: translate 
"\n" to "\r\n".

It would be nice to fix this before Python 3.3 final.

----------
keywords: +patch
nosy: +georg.brandl
priority: normal -> release blocker
Added file: http://bugs.python.org/file26644/windows_stdout_newline.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13119>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to