mirror of
https://github.com/python/cpython.git
synced 2025-07-13 14:25:18 +00:00
[3.11] gh-99103: Normalize specialized traceback anchors against the current line (#99423)
[3.11] gh-99103: Normalize specialized traceback anchors against the current line (GH-99145)
Automerge-Triggered-By: GH:isidentical.
(cherry picked from commit 57be545959
)
Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
This commit is contained in:
parent
2d5f4ba174
commit
a3480ec795
4 changed files with 51 additions and 5 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue