Skip to content

Commit 8fbcd37

Browse files
committed
gh-153569: fix multiline continuation error offsets
1 parent 77aa037 commit 8fbcd37

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

Lib/test/test_syntax.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3393,6 +3393,10 @@ def test_invalid_line_continuation_error_position(self):
33933393
self._check_error('\nfgdfgf\n1,\\#\n2\n',
33943394
"unexpected character after line continuation character",
33953395
lineno=3, offset=4)
3396+
for prefix in ("f", "t"):
3397+
self._check_error(f'{prefix}"""{{\n\\ x}}"""',
3398+
"unexpected character after line continuation character",
3399+
lineno=2, offset=2)
33963400

33973401
def test_invalid_line_continuation_left_recursive(self):
33983402
# Check bpo-42218: SyntaxErrors following left-recursive rules

Parser/pegen_errors.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ _Pypegen_tokenizer_error(Parser *p)
6363
msg = "too many levels of indentation";
6464
break;
6565
case E_LINECONT: {
66-
col_offset = p->tok->cur - p->tok->buf - 1;
66+
col_offset = p->tok->cur - p->tok->line_start - 1;
6767
msg = "unexpected character after line continuation character";
6868
break;
6969
}

0 commit comments

Comments
 (0)