[issue11990] redirected output - stdout writes newline as \n in windows

Peter Csapo report at bugs.python.org
Mon Jan 9 08:12:53 CET 2012


Peter Csapo <astrobuf at gmail.com> added the comment:

I have having the same issues as Jimbofbx. This seems to stem from changes due to issue 10841. All stdio is now opened in binary mode, in consideration that it is the TextIOWrapper's job to do endline translation.

The problem here is that the newline mode = '\n' for the TextIOWrapper created for stdout. ( see pythonrun.c: create_stdio() ). For windows, the newline mode for stdin is already set to null enabling universal newline translation on input, and it should be set to null for newline transation on output as well.

OLD CODE
newline = "\n";
#ifdef MS_WINDOWS
if (!write_mode) {
    /* translate \r\n to \n for sys.stdin on Windows */
    newline = NULL;
}
#endif


FIXED??? CODE
newline = "\n";
#ifdef MS_WINDOWS
/* translate \r\n to \n for sys.stdin on Windows */
/* translate \n to \r\n for sys.stdout on Windows */
newline = NULL;
#endif

----------
nosy: +astrobuf

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11990>
_______________________________________


More information about the Python-bugs-list mailing list