mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
bpo-46237: Fix the line number of tokenizer errors inside f-strings (GH-30463)
(cherry picked from commit 6fa8b2ceee)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
This commit is contained in:
parent
4cfb10979d
commit
19a85501ce
4 changed files with 22 additions and 5 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue