Skip to content

Commit

Permalink
bpo-38673: dont switch to ps2 if the line starts with comment or whit…
Browse files Browse the repository at this point in the history
  • Loading branch information
isidentical authored and miss-islington committed Dec 9, 2019
1 parent 3ae4ea1 commit 109fc27
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In REPL mode, don't switch to PS2 if the line starts with comment or whitespace. Based on work by Batuhan Taşkaya.
6 changes: 6 additions & 0 deletions Parser/tokenizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
}
Expand Down

0 comments on commit 109fc27

Please sign in to comment.