mirror of
https://github.com/python/cpython.git
synced 2025-08-27 20:25:18 +00:00
gh-116042: Fix location for SyntaxErrors of invalid escapes in the tokenizer (#116049)
This commit is contained in:
parent
49b11033bd
commit
56eda25633
5 changed files with 80 additions and 17 deletions
|
@ -352,8 +352,8 @@ _PyPegen_raise_error_known_location(Parser *p, PyObject *errtype,
|
|||
assert(p->tok->fp == NULL || p->tok->fp == stdin || p->tok->done == E_EOF);
|
||||
|
||||
if (p->tok->lineno <= lineno && p->tok->inp > p->tok->buf) {
|
||||
Py_ssize_t size = p->tok->inp - p->tok->buf;
|
||||
error_line = PyUnicode_DecodeUTF8(p->tok->buf, size, "replace");
|
||||
Py_ssize_t size = p->tok->inp - p->tok->line_start;
|
||||
error_line = PyUnicode_DecodeUTF8(p->tok->line_start, size, "replace");
|
||||
}
|
||||
else if (p->tok->fp == NULL || p->tok->fp == stdin) {
|
||||
error_line = get_error_line_from_tokenizer_buffers(p, lineno);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue