diff options
Diffstat (limited to 'Python/ast.c')
-rw-r--r-- | Python/ast.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Python/ast.c b/Python/ast.c index 69dfe3c..d71f44a 100644 --- a/Python/ast.c +++ b/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); |