mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #10841: set binary mode on files; the parser translates newlines
On Windows, set the binary mode on stdin, stdout, stderr and all io.FileIO objects (to not translate newlines, \r\n <=> \n). The Python parser translates newlines (\r\n => \n).
This commit is contained in:
parent
bdde506116
commit
89e3436606
4 changed files with 22 additions and 3 deletions
|
@ -892,6 +892,13 @@ tok_nextc(register struct tok_state *tok)
|
|||
}
|
||||
if (tok->prompt != NULL) {
|
||||
char *newtok = PyOS_Readline(stdin, stdout, tok->prompt);
|
||||
if (newtok != NULL) {
|
||||
char *translated = translate_newlines(newtok, 0, tok);
|
||||
PyMem_FREE(newtok);
|
||||
if (translated == NULL)
|
||||
return EOF;
|
||||
newtok = translated;
|
||||
}
|
||||
#ifndef PGEN
|
||||
if (tok->encoding && newtok && *newtok) {
|
||||
/* Recode to UTF-8 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue