mirror of
https://github.com/python/cpython.git
synced 2025-07-17 08:15:19 +00:00
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.
This commit is contained in:
parent
d1f9352bd4
commit
7b3f0fa68e
3 changed files with 28 additions and 5 deletions
|
@ -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",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue