mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
[3.12] gh-106922: Fix error location for constructs with spaces and parentheses (GH-108959) (#109147)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
This commit is contained in:
parent
a1ba0e531c
commit
af83d1e821
4 changed files with 68 additions and 3 deletions
|
@ -608,11 +608,21 @@ def _extract_caret_anchors_from_line_segment(segment):
|
|||
and not operator_str[operator_offset + 1].isspace()
|
||||
):
|
||||
right_anchor += 1
|
||||
|
||||
while left_anchor < len(segment) and ((ch := segment[left_anchor]).isspace() or ch in ")#"):
|
||||
left_anchor += 1
|
||||
right_anchor += 1
|
||||
return _Anchors(normalize(left_anchor), normalize(right_anchor))
|
||||
case ast.Subscript():
|
||||
subscript_start = normalize(expr.value.end_col_offset)
|
||||
subscript_end = normalize(expr.slice.end_col_offset + 1)
|
||||
return _Anchors(subscript_start, subscript_end)
|
||||
left_anchor = normalize(expr.value.end_col_offset)
|
||||
right_anchor = normalize(expr.slice.end_col_offset + 1)
|
||||
while left_anchor < len(segment) and ((ch := segment[left_anchor]).isspace() or ch != "["):
|
||||
left_anchor += 1
|
||||
while right_anchor < len(segment) and ((ch := segment[right_anchor]).isspace() or ch != "]"):
|
||||
right_anchor += 1
|
||||
if right_anchor < len(segment):
|
||||
right_anchor += 1
|
||||
return _Anchors(left_anchor, right_anchor)
|
||||
|
||||
return None
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue