mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
gh-99103: Normalize specialized traceback anchors against the current line (GH-99145)
Automerge-Triggered-By: GH:isidentical
This commit is contained in:
parent
c95f554a40
commit
57be545959
4 changed files with 53 additions and 7 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue