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-91153: Handle mutating __index__ methods in bytearray item assignment #94891

Merged
merged 6 commits into from
Jul 19, 2022

Conversation

brandtbucher
Copy link
Member

@brandtbucher brandtbucher commented Jul 15, 2022

This creates a (very slight) change in semantics. Previously, an assignment to an invalid index would raise without calling __index__. Now, it calls __index__ and then raises. I really doubt it's an issue in practice, though.

Also, add some missing nearby braces.

@brandtbucher brandtbucher added needs backport to 3.10 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump needs backport to 3.11 only security fixes labels Jul 15, 2022
@brandtbucher brandtbucher self-assigned this Jul 15, 2022
Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

The change in semantics seems fine; I don't think we provide guarantees on when dunders like __index__ are called.

@miss-islington
Copy link
Contributor

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

@miss-islington
Copy link
Contributor

Sorry @brandtbucher, I had trouble checking out the 3.11 backport branch.
Please backport using cherry_picker on command line.
cherry_picker f36589510b8708fa224d799d5b328deab558aa4e 3.11

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 19, 2022
…ssignment (pythonGH-94891)

(cherry picked from commit f365895)

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

GH-95013 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Jul 19, 2022
@brandtbucher brandtbucher added needs backport to 3.11 only security fixes and removed needs backport to 3.11 only security fixes labels Jul 19, 2022
@miss-islington
Copy link
Contributor

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

@bedevere-bot
Copy link

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

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Jul 19, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 19, 2022
…ssignment (pythonGH-94891)

(cherry picked from commit f365895)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
miss-islington added a commit that referenced this pull request Jul 19, 2022
…ent (GH-94891)

(cherry picked from commit f365895)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
miss-islington added a commit that referenced this pull request Jul 19, 2022
…ent (GH-94891)

(cherry picked from commit f365895)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
@brandtbucher brandtbucher deleted the mutating-bytearray-index branch July 21, 2022 19:41
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-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants