Skip to content

Commit 13dadaa

Browse files
committed
bpo-39209: Manage correctly multi-line tokens in interactive mode
1 parent ee94bdb commit 13dadaa

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Correctly handle multi-line tokens in interactive mode. Patch by Pablo
2+
Galindo.

Parser/tokenizer.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,7 @@ tok_nextc(struct tok_state *tok)
886886
size_t start = tok->start - tok->buf;
887887
size_t oldlen = tok->cur - tok->buf;
888888
size_t newlen = oldlen + strlen(newtok);
889+
Py_ssize_t cur_multi_line_start = tok->multi_line_start - tok->buf;
889890
char *buf = tok->buf;
890891
buf = (char *)PyMem_REALLOC(buf, newlen+1);
891892
tok->lineno++;
@@ -898,6 +899,7 @@ tok_nextc(struct tok_state *tok)
898899
}
899900
tok->buf = buf;
900901
tok->cur = tok->buf + oldlen;
902+
tok->multi_line_start = tok->buf + cur_multi_line_start;
901903
tok->line_start = tok->cur;
902904
strcpy(tok->buf + oldlen, newtok);
903905
PyMem_FREE(newtok);

0 commit comments

Comments
 (0)