summaryrefslogtreecommitdiff
path: root/Parser
diff options
context:
space:
mode:
authorBatuhan Taşkaya <47358913+isidentical@users.noreply.github.com>2019-12-09 07:36:27 +0300
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-12-08 20:36:27 -0800
commit109fc2792a490ee5cd8a423e17d415fbdedec5c8 (patch)
treeec14be7f6abcb0760cc94a920cf783ec5319f850 /Parser
parent3ae4ea1931361dd2743e464790e739d9285501bf (diff)
downloadcpython-git-109fc2792a490ee5cd8a423e17d415fbdedec5c8.tar.gz
bpo-38673: dont switch to ps2 if the line starts with comment or whitespace (GH-17421)
https://bugs.python.org/issue38673
Diffstat (limited to 'Parser')
-rw-r--r--Parser/tokenizer.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 5763e47c4b..f84093dae5 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -1148,6 +1148,12 @@ tok_get(struct tok_state *tok, char **p_start, char **p_end)
if (col == 0 && c == '\n' && tok->prompt != NULL) {
blankline = 0; /* Let it through */
}
+ else if (tok->prompt != NULL && tok->lineno == 1) {
+ /* In interactive mode, if the first line contains
+ only spaces and/or a comment, let it through. */
+ blankline = 0;
+ col = altcol = 0;
+ }
else {
blankline = 1; /* Ignore completely */
}