summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2012-08-03 23:28:00 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2012-08-03 23:28:00 (GMT)
commit7b3f0fa68e320253e7dc6987c54206272ffb182a (patch)
tree6d44a1a1153a2055b99f4817150bb380890d1aa1 /Python
parentd1f9352bd4b30ccfe665109b1341433a00dc6256 (diff)
downloadcpython-7b3f0fa68e320253e7dc6987c54206272ffb182a.zip
cpython-7b3f0fa68e320253e7dc6987c54206272ffb182a.tar.gz
cpython-7b3f0fa68e320253e7dc6987c54206272ffb182a.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')
-rw-r--r--Python/pythonrun.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index cafc09a..05dfb8e 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",