mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Issue #10841: set binary mode on files; the parser translates newlines
On Windows, set the binary mode on stdin, stdout, stderr and all io.FileIO objects (to not translate newlines, \r\n <=> \n). The Python parser translates newlines (\r\n => \n).
This commit is contained in:
parent
bdde506116
commit
89e3436606
4 changed files with 22 additions and 3 deletions
|
@ -527,11 +527,14 @@ Py_Main(int argc, wchar_t **argv)
|
|||
|
||||
stdin_is_interactive = Py_FdIsInteractive(stdin, (char *)0);
|
||||
|
||||
if (Py_UnbufferedStdioFlag) {
|
||||
#if defined(MS_WINDOWS) || defined(__CYGWIN__)
|
||||
_setmode(fileno(stdin), O_BINARY);
|
||||
_setmode(fileno(stdout), O_BINARY);
|
||||
/* don't translate newlines (\r\n <=> \n) */
|
||||
_setmode(fileno(stdin), O_BINARY);
|
||||
_setmode(fileno(stdout), O_BINARY);
|
||||
_setmode(fileno(stderr), O_BINARY);
|
||||
#endif
|
||||
|
||||
if (Py_UnbufferedStdioFlag) {
|
||||
#ifdef HAVE_SETVBUF
|
||||
setvbuf(stdin, (char *)NULL, _IONBF, BUFSIZ);
|
||||
setvbuf(stdout, (char *)NULL, _IONBF, BUFSIZ);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue