diff options
Diffstat (limited to 'Python/compile.c')
-rw-r--r-- | Python/compile.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Python/compile.c b/Python/compile.c index f36a6e8..427fb2a 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -4736,8 +4736,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_loc.lineno = meth->end_lineno; - c->u->u_loc.col_offset = meth->end_col_offset - (int)PyUnicode_GetLength(meth->v.Attribute.attr)-1; + c->u->u_loc.lineno = c->u->u_loc.end_lineno = meth->end_lineno; + int len = (int)PyUnicode_GET_LENGTH(meth->v.Attribute.attr); + if (len <= meth->end_col_offset) { + c->u->u_loc.col_offset = meth->end_col_offset - len; + } + else { + // GH-94694: Somebody's compiling weird ASTs. Just drop the columns: + c->u->u_loc.col_offset = c->u->u_loc.end_col_offset = -1; + } } } |