-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attribute node in a decorator has wrong end_col_offset #83760
Comments
There is a problem with the end_col_offset of nested Attribute nodes in decorators. For example, parsing @a.b.c
def f(): pass produces the following AST tree (part): decorator_list=[
Attribute(
value=Attribute(
value=Name(
id="a",
ctx=Load(),
lineno=1,
col_offset=1,
end_lineno=1,
end_col_offset=2,
),
attr="b",
ctx=Load(),
lineno=1,
col_offset=1,
end_lineno=1,
*end_col_offset=6*,
),
attr="c",
ctx=Load(),
lineno=1,
col_offset=1,
end_lineno=1,
end_col_offset=6,
)
], Note that the Attribute node with attr="b" has end_col_offset=6, while it should actually be 4. |
Note: this change causes a regression in kdev-python because our code was based on (and worked around) the long-standing previous behaviour; it produces broken results given the 'fixed' offset. I shall have to write a patch with a version-check before our next stable release. While the new behaviour is more logical, I'm not convinced that deliberate API breakage in a stable release - for something that's not a recent regression - was a good idea. |
Sorry, on further inspection it was the other AST range change https://bugs.python.org/issue39474 , not this one. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: