summaryrefslogtreecommitdiffstats
path: root/Parser/pegen.c
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-01-11 16:33:08 (GMT)
committerGitHub <noreply@github.com>2022-01-11 16:33:08 (GMT)
commit19a85501cee24a6e426a431243d0adcb5664c6fe (patch)
tree7fb844c0e7948a049d72a301251fb77fc1f59027 /Parser/pegen.c
parent4cfb10979d74b8513ec751b81454709f38e3b51a (diff)
downloadcpython-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/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 0504906..e507415 100644
--- a/Parser/pegen.c
+++ b/Parser/pegen.c
@@ -701,10 +701,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;