diff options
Diffstat (limited to 'Python')
-rw-r--r-- | Python/traceback.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Python/traceback.c b/Python/traceback.c index 20348c0..7f47349 100644 --- a/Python/traceback.c +++ b/Python/traceback.c @@ -705,8 +705,13 @@ extract_anchors_from_line(PyObject *filename, PyObject *line, done: if (res > 0) { - *left_anchor += start_offset; - *right_anchor += start_offset; + // Normalize the AST offsets to byte offsets and adjust them with the + // start of the actual line (instead of the source code segment). + assert(segment != NULL); + assert(*left_anchor >= 0); + assert(*right_anchor >= 0); + *left_anchor = _PyPegen_byte_offset_to_character_offset(segment, *left_anchor) + start_offset; + *right_anchor = _PyPegen_byte_offset_to_character_offset(segment, *right_anchor) + start_offset; } Py_XDECREF(segment); if (arena) { |