mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-39209: Manage correctly multi-line tokens in interactive mode (GH-17860)
This commit is contained in:
parent
075ebad369
commit
5ec91f78d5
3 changed files with 40 additions and 0 deletions
|
@ -886,6 +886,7 @@ tok_nextc(struct tok_state *tok)
|
|||
size_t start = tok->start - tok->buf;
|
||||
size_t oldlen = tok->cur - tok->buf;
|
||||
size_t newlen = oldlen + strlen(newtok);
|
||||
Py_ssize_t cur_multi_line_start = tok->multi_line_start - tok->buf;
|
||||
char *buf = tok->buf;
|
||||
buf = (char *)PyMem_REALLOC(buf, newlen+1);
|
||||
tok->lineno++;
|
||||
|
@ -898,6 +899,7 @@ tok_nextc(struct tok_state *tok)
|
|||
}
|
||||
tok->buf = buf;
|
||||
tok->cur = tok->buf + oldlen;
|
||||
tok->multi_line_start = tok->buf + cur_multi_line_start;
|
||||
tok->line_start = tok->cur;
|
||||
strcpy(tok->buf + oldlen, newtok);
|
||||
PyMem_FREE(newtok);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue