summaryrefslogtreecommitdiffstats
path: root/Parser/tokenizer.c
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-12-09 04:56:19 (GMT)
committerGitHub <noreply@github.com>2019-12-09 04:56:19 (GMT)
commit184a3812b81e2f7d4bc6453bf7ceabe8ac590202 (patch)
treef2a1b2d0bd3066c71333de95c39c8be90c975b83 /Parser/tokenizer.c
parent2abd3a8f580e6c7b1ce88b2ae9f9a783f4aea5d3 (diff)
downloadcpython-184a3812b81e2f7d4bc6453bf7ceabe8ac590202.zip
cpython-184a3812b81e2f7d4bc6453bf7ceabe8ac590202.tar.gz
cpython-184a3812b81e2f7d4bc6453bf7ceabe8ac590202.tar.bz2
bpo-38673: dont switch to ps2 if the line starts with comment or whitespace (GH-17421)
https://bugs.python.org/issue38673 (cherry picked from commit 109fc2792a490ee5cd8a423e17d415fbdedec5c8) Co-authored-by: Batuhan Taşkaya <47358913+isidentical@users.noreply.github.com>
Diffstat (limited to 'Parser/tokenizer.c')
-rw-r--r--Parser/tokenizer.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 5763e47..f84093d 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 */
}