mirror of
https://github.com/python/cpython.git
synced 2025-08-27 12:16:04 +00:00
[3.11] GH-94694: Fix column offsets for multi-line method lookups (GH-94721)
(cherry picked from commit 264b3ddfd5
)
This commit is contained in:
parent
7b5737a51a
commit
e5c8ad3e15
4 changed files with 85 additions and 2 deletions
|
@ -4788,8 +4788,15 @@ update_location_to_match_attr(struct compiler *c, expr_ty meth)
|
|||
{
|
||||
if (meth->lineno != meth->end_lineno) {
|
||||
// Make start location match attribute
|
||||
c->u->u_lineno = meth->end_lineno;
|
||||
c->u->u_col_offset = meth->end_col_offset - (int)PyUnicode_GetLength(meth->v.Attribute.attr)-1;
|
||||
c->u->u_lineno = c->u->u_end_lineno = meth->end_lineno;
|
||||
int len = (int)PyUnicode_GET_LENGTH(meth->v.Attribute.attr);
|
||||
if (len <= meth->end_col_offset) {
|
||||
c->u->u_col_offset = meth->end_col_offset - len;
|
||||
}
|
||||
else {
|
||||
// GH-94694: Somebody's compiling weird ASTs. Just drop the columns:
|
||||
c->u->u_col_offset = c->u->u_end_col_offset = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue