mirror of
https://github.com/python/cpython.git
synced 2025-09-02 23:18:25 +00:00
bpo-16806: Fix lineno
and col_offset
for multi-line string tokens (GH-10021)
This commit is contained in:
parent
1cffd0eed3
commit
995d9b9297
13 changed files with 91 additions and 51 deletions
10
Python/ast.c
10
Python/ast.c
|
@ -4284,9 +4284,13 @@ fstring_fix_node_location(const node *parent, node *n, char *expr_str)
|
|||
start--;
|
||||
}
|
||||
cols += (int)(substr - start);
|
||||
/* Fix lineno in mulitline strings. */
|
||||
while ((substr = strchr(substr + 1, '\n')))
|
||||
lines--;
|
||||
/* adjust the start based on the number of newlines encountered
|
||||
before the f-string expression */
|
||||
for (char* p = parent->n_str; p < substr; p++) {
|
||||
if (*p == '\n') {
|
||||
lines++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fstring_shift_node_locations(n, lines, cols);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue