diff Python/pythonrun.c @ 78405:c55dbb84f3b4

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.
author Victor Stinner <victor.stinner@gmail.com>
date Sat, 04 Aug 2012 01:28:00 +0200
parents 2f1494d243ad
children 92c6bbf7bb85
line wrap: on
line diff
--- a/Python/pythonrun.c	Sat Aug 04 01:22:07 2012 +0200
+++ b/Python/pythonrun.c	Sat Aug 04 01:28:00 2012 +0200
@@ -971,12 +971,15 @@
     Py_CLEAR(raw);
     Py_CLEAR(text);
 
+#ifdef MS_WINDOWS
+    /* 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";
-#ifdef MS_WINDOWS
-    if (!write_mode) {
-        /* translate \r\n to \n for sys.stdin on Windows */
-        newline = NULL;
-    }
 #endif
 
     stream = _PyObject_CallMethodId(io, &PyId_TextIOWrapper, "OsssO",