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).
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index 2361636..2e5d7ac 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -388,6 +388,11 @@
goto error;
}
+#if defined(MS_WINDOWS) || defined(__CYGWIN__)
+ /* don't translate newlines (\r\n <=> \n) */
+ _setmode(self->fd, O_BINARY);
+#endif
+
if (PyObject_SetAttrString((PyObject *)self, "name", nameobj) < 0)
goto error;