diff options
author | Batuhan Taskaya <batuhan@python.org> | 2021-07-20 15:42:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-20 15:42:12 (GMT) |
commit | fbc349ff790c21f1a59af939d42033470790c530 (patch) | |
tree | 8de9aad662539dc3c643c1ec1ecfaaf1d54f8af8 /Python | |
parent | 4868b94c6089d457673b1ba5b5b64c2f38c435af (diff) | |
download | cpython-fbc349ff790c21f1a59af939d42033470790c530.zip cpython-fbc349ff790c21f1a59af939d42033470790c530.tar.gz cpython-fbc349ff790c21f1a59af939d42033470790c530.tar.bz2 |
bpo-43950: Distinguish errors happening on character offset decoding (GH-27217)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/traceback.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Python/traceback.c b/Python/traceback.c index 643096c..e02caef 100644 --- a/Python/traceback.c +++ b/Python/traceback.c @@ -745,7 +745,17 @@ tb_displayline(PyTracebackObject* tb, PyObject *f, PyObject *filename, int linen // Convert the utf-8 byte offset to the actual character offset so we print the right number of carets. assert(source_line); Py_ssize_t start_offset = _PyPegen_byte_offset_to_character_offset(source_line, start_col_byte_offset); + if (start_offset < 0) { + err = ignore_source_errors() < 0; + goto done; + } + Py_ssize_t end_offset = _PyPegen_byte_offset_to_character_offset(source_line, end_col_byte_offset); + if (end_offset < 0) { + err = ignore_source_errors() < 0; + goto done; + } + Py_ssize_t left_end_offset = -1; Py_ssize_t right_start_offset = -1; |