8000 GH-94036: Fix more attribute location quirks by brandtbucher · Pull Request #95028 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-94036: Fix more attribute location quirks #95028

8000
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

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 An unexpected behavior, bug, or error interpreter-core (Objects, Python, Grammar, and Parser dirs) needs backport to 3.11 only security fixes labels Jul 19, 2022
@brandtbucher brandtbucher self-assigned this Jul 19, 2022
@iritkatriel
Copy link
Member

LGTM

@miss-islington
Copy link
Contributor

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 July 22, 2022 20:13
@miss-islington
Copy link
Contributor

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 pull request Jul 23, 2022
…5028).

(cherry picked from commit 900bfc5)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Jul 23, 2022
@bedevere-bot
Copy link

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

brandtbucher added a commit that referenced this pull request Jul 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0