diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2023-11-27 18:37:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-27 18:37:48 (GMT) |
commit | 45d648597b1146431bf3d91041e60d7f040e70bf (patch) | |
tree | 28d15909930323f788e32e2b67263f1d9a026bb1 /Parser | |
parent | 2c8b19174274c183eb652932871f60570123fe99 (diff) | |
download | cpython-45d648597b1146431bf3d91041e60d7f040e70bf.zip cpython-45d648597b1146431bf3d91041e60d7f040e70bf.tar.gz cpython-45d648597b1146431bf3d91041e60d7f040e70bf.tar.bz2 |
gh-112387: Fix error positions for decoded strings with backwards tokenize errors (#112409)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/pegen_errors.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Parser/pegen_errors.c b/Parser/pegen_errors.c index 2528d45..20232f3 100644 --- a/Parser/pegen_errors.c +++ b/Parser/pegen_errors.c @@ -282,6 +282,10 @@ get_error_line_from_tokenizer_buffers(Parser *p, Py_ssize_t lineno) Py_ssize_t relative_lineno = p->starting_lineno ? lineno - p->starting_lineno + 1 : lineno; const char* buf_end = p->tok->fp_interactive ? p->tok->interactive_src_end : p->tok->inp; + if (buf_end < cur_line) { + buf_end = cur_line + strlen(cur_line); + } + for (int i = 0; i < relative_lineno - 1; i++) { char *new_line = strchr(cur_line, '\n'); // The assert is here for debug builds but the conditional that |