Skip to content
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

GH-94036: Fix more attribute location quirks #95028

Merged
merged 7 commits into from Jul 22, 2022

Conversation

brandtbucher
Copy link
Member

@brandtbucher brandtbucher commented Jul 19, 2022

This fixes several quirks in the location info generated for multiline attribute accesses and method calls:

  • It unifies the many places where we hack up the location info for Attribute nodes. Many of these did not bother with updating column offsets, and could produce nonsensical ranges as a result.
  • It modifies update_location_to_match_attr to leave end location info alone (so that things like method calls have correct spans), and renames it to update_start_location_to_match_attr to reflect this.
  • It adds protections against producing invalid changes when given weird pytest-like ASTs that nevertheless have valid locations for each node.
  • It also adds this location modification logic to multiline attribute deletions, which were (apparently?) overlooked.

@brandtbucher brandtbucher added type-bug interpreter-core needs backport to 3.11 labels Jul 19, 2022
@brandtbucher brandtbucher self-assigned this Jul 19, 2022
@brandtbucher brandtbucher requested a review from markshannon as a code owner Jul 19, 2022
@iritkatriel
Copy link
Member

@iritkatriel iritkatriel commented Jul 22, 2022

LGTM

@brandtbucher brandtbucher merged commit 900bfc5 into python:main Jul 22, 2022
14 checks passed
@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jul 22, 2022

Thanks @brandtbucher for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒🤖

@brandtbucher brandtbucher deleted the more-attr-location-quirks branch Jul 22, 2022
@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jul 22, 2022

Sorry, @brandtbucher, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 900bfc53cb133e8bc2b122362ec04256f623d5b0 3.11

brandtbucher added a commit to brandtbucher/cpython that referenced this issue Jul 23, 2022
…5028).

(cherry picked from commit 900bfc5)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Jul 23, 2022

GH-95156 is a backport of this pull request to the 3.11 branch.

brandtbucher added a commit that referenced this issue Jul 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core type-bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants