File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -4737,7 +4737,19 @@ update_location_to_match_attr(struct compiler *c, expr_ty meth)
4737
4737
if (meth -> lineno != meth -> end_lineno ) {
4738
4738
// Make start location match attribute
4739
4739
c -> u -> u_loc .lineno = meth -> end_lineno ;
4740
- c -> u -> u_loc .col_offset = meth -> end_col_offset - (int )PyUnicode_GetLength (meth -> v .Attribute .attr )- 1 ;
4740
+ int len = (int )PyUnicode_GET_LENGTH (meth -> v .Attribute .attr );
4741
+ // The dot may or not be on this line. Don't try to include it in the
4742
+ // column span, it's more trouble than it's worth:
4743
+ if (len <= meth -> end_col_offset ) {
4744
+ // |---- end_col_offset
4745
+ // .method(...)
4746
+ // |---------- new col_offset
4747
+ c -> u -> u_loc .col_offset = meth -> end_col_offset - len ;
4748
+ }
4749
+ else {
4750
+ // GH-94694: Somebody's compiling weird ASTs. Just drop the columns:
4751
+ c -> u -> u_loc .col_offset = c -> u -> u_loc .end_col_offset = -1 ;
4752
+ }
4741
4753
}
4742
4754
}
4743
4755
You can’t perform that action at this time.
0 commit comments