diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2012-08-03 23:37:32 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2012-08-03 23:37:32 (GMT) |
commit | 90ef747e04ee586ef475b8ef03d3548e5059b105 (patch) | |
tree | 2be3b143ad927947a40c287a2b47234a035162da /Python/pythonrun.c | |
parent | 401e17d0f06dd6594835424c5544689abdc0cc9f (diff) | |
download | cpython-90ef747e04ee586ef475b8ef03d3548e5059b105.zip cpython-90ef747e04ee586ef475b8ef03d3548e5059b105.tar.gz cpython-90ef747e04ee586ef475b8ef03d3548e5059b105.tar.bz2 |
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 4609468..cf4e34c 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -870,12 +870,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_CallMethod(io, "TextIOWrapper", "OsssO", |