summaryrefslogtreecommitdiffstats
path: root/Modules/_io
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-01-07 18:47:22 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-01-07 18:47:22 (GMT)
commit89e343660623862acbd40cc617b4af262d6c799f (patch)
tree6ffb758ccc88b03797670e983e9e2917a33fc77c /Modules/_io
parentbdde5061163bd773f56e3774f38fa80344267f6f (diff)
downloadcpython-89e343660623862acbd40cc617b4af262d6c799f.zip
cpython-89e343660623862acbd40cc617b4af262d6c799f.tar.gz
cpython-89e343660623862acbd40cc617b4af262d6c799f.tar.bz2
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).
Diffstat (limited to 'Modules/_io')
-rw-r--r--Modules/_io/fileio.c5
1 files changed, 5 insertions, 0 deletions
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 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
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;