diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-01-11 16:33:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-11 16:33:08 (GMT) |
commit | 19a85501cee24a6e426a431243d0adcb5664c6fe (patch) | |
tree | 7fb844c0e7948a049d72a301251fb77fc1f59027 /Parser/string_parser.c | |
parent | 4cfb10979d74b8513ec751b81454709f38e3b51a (diff) | |
download | cpython-19a85501cee24a6e426a431243d0adcb5664c6fe.zip cpython-19a85501cee24a6e426a431243d0adcb5664c6fe.tar.gz cpython-19a85501cee24a6e426a431243d0adcb5664c6fe.tar.bz2 |
bpo-46237: Fix the line number of tokenizer errors inside f-strings (GH-30463)
(cherry picked from commit 6fa8b2ceee38187b0ae96aee12fe4f0a5c8a2ce7)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Diffstat (limited to 'Parser/string_parser.c')
-rw-r--r-- | Parser/string_parser.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Parser/string_parser.c b/Parser/string_parser.c index dcd298c..c83e63f 100644 --- a/Parser/string_parser.c +++ b/Parser/string_parser.c @@ -392,11 +392,14 @@ fstring_compile_expr(Parser *p, const char *expr_start, const char *expr_end, return NULL; } Py_INCREF(p->tok->filename); + tok->filename = p->tok->filename; + tok->lineno = t->lineno + lines - 1; Parser *p2 = _PyPegen_Parser_New(tok, Py_fstring_input, p->flags, p->feature_version, NULL, p->arena); - p2->starting_lineno = t->lineno + lines - 1; + + p2->starting_lineno = t->lineno + lines; p2->starting_col_offset = t->col_offset + cols; expr = _PyPegen_run_parser(p2); |