diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2012-08-04 01:28:00 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2012-08-04 01:28:00 +0200 |
commit | 18f37321ab18672f72c9fa42a9fd143e4b731fb5 (patch) | |
tree | 82a8081da4a2e8b8d2ab5662a6be8f58bf4916fb /Python/pythonrun.c | |
parent | d7e7b26456f5bb9b39c66b1671d944f8b6562d50 (diff) | |
download | cpython-18f37321ab18672f72c9fa42a9fd143e4b731fb5.tar.gz |
Close #13119: use "\r\n" newline for sys.stdout/err on Windows
sys.stdout and sys.stderr are now using "\r\n" newline on Windows, as Python 2.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index cafc09ac3f..05dfb8e1d0 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -971,12 +971,15 @@ create_stdio(PyObject* io, Py_CLEAR(raw); Py_CLEAR(text); - newline = "\n"; #ifdef MS_WINDOWS - if (!write_mode) { - /* translate \r\n to \n for sys.stdin on Windows */ - newline = NULL; - } + /* sys.stdin: enable universal newline mode, translate "\r\n" and "\r" + newlines to "\n". + sys.stdout and sys.stderr: translate "\n" to "\r\n". */ + newline = NULL; +#else + /* sys.stdin: split lines at "\n". + sys.stdout and sys.stderr: don't translate newlines (use "\n"). */ + newline = "\n"; #endif stream = _PyObject_CallMethodId(io, &PyId_TextIOWrapper, "OsssO", |