summaryrefslogtreecommitdiffstats
path: root/Parser/pegen.c
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2022-01-08 00:23:40 (GMT)
committerGitHub <noreply@github.com>2022-01-08 00:23:40 (GMT)
commit6fa8b2ceee38187b0ae96aee12fe4f0a5c8a2ce7 (patch)
tree22f9edf799bc7020af220b609b7dbb655e34b106 /Parser/pegen.c
parentd81182b8ec3b1593daf241d44757a9fa68fd14cc (diff)
downloadcpython-6fa8b2ceee38187b0ae96aee12fe4f0a5c8a2ce7.zip
cpython-6fa8b2ceee38187b0ae96aee12fe4f0a5c8a2ce7.tar.gz
cpython-6fa8b2ceee38187b0ae96aee12fe4f0a5c8a2ce7.tar.bz2
bpo-46237: Fix the line number of tokenizer errors inside f-strings (GH-30463)
Diffstat (limited to 'Parser/pegen.c')
-rw-r--r--Parser/pegen.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/Parser/pegen.c b/Parser/pegen.c
index cfea1c8..470c2cb 100644
--- a/Parser/pegen.c
+++ b/Parser/pegen.c
@@ -179,10 +179,10 @@ initialize_token(Parser *p, Token *token, const char *start, const char *end, in
int col_offset = (start != NULL && start >= line_start) ? (int)(start - line_start) : -1;
int end_col_offset = (end != NULL && end >= p->tok->line_start) ? (int)(end - p->tok->line_start) : -1;
- token->lineno = p->starting_lineno + lineno;
- token->col_offset = p->tok->lineno == 1 ? p->starting_col_offset + col_offset : col_offset;
- token->end_lineno = p->starting_lineno + end_lineno;
- token->end_col_offset = p->tok->lineno == 1 ? p->starting_col_offset + end_col_offset : end_col_offset;
+ token->lineno = lineno;
+ token->col_offset = p->tok->lineno == p->starting_lineno ? p->starting_col_offset + col_offset : col_offset;
+ token->end_lineno = end_lineno;
+ token->end_col_offset = p->tok->lineno == p->starting_lineno ? p->starting_col_offset + end_col_offset : end_col_offset;
p->fill += 1;