diff options
author | Batuhan Taskaya <isidentical@gmail.com> | 2022-11-12 23:37:25 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-12 23:37:25 (GMT) |
commit | 57be5459593bbd09583317ebdafc4d58ae51dbf4 (patch) | |
tree | b730c61cc81558a94898b1ffb603a5b42210fd26 /Python | |
parent | c95f554a408f76f96c14c006ebe8a0d3d3b40765 (diff) | |
download | cpython-57be5459593bbd09583317ebdafc4d58ae51dbf4.zip cpython-57be5459593bbd09583317ebdafc4d58ae51dbf4.tar.gz cpython-57be5459593bbd09583317ebdafc4d58ae51dbf4.tar.bz2 |
gh-99103: Normalize specialized traceback anchors against the current line (GH-99145)
Automerge-Triggered-By: GH:isidentical
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 aacdb33..356e643 100644 --- a/Python/traceback.c +++ b/Python/traceback.c @@ -700,8 +700,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) { |