summaryrefslogtreecommitdiffstats
path: root/Parser/tokenizer.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-01-07 18:47:22 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-01-07 18:47:22 (GMT)
commit89e343660623862acbd40cc617b4af262d6c799f (patch)
tree6ffb758ccc88b03797670e983e9e2917a33fc77c /Parser/tokenizer.c
parentbdde5061163bd773f56e3774f38fa80344267f6f (diff)
downloadcpython-89e343660623862acbd40cc617b4af262d6c799f.zip
cpython-89e343660623862acbd40cc617b4af262d6c799f.tar.gz
cpython-89e343660623862acbd40cc617b4af262d6c799f.tar.bz2
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).
Diffstat (limited to 'Parser/tokenizer.c')
-rw-r--r--Parser/tokenizer.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 556be46..1eb62aa 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -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 */