Repository navigation
Fix subclass __getattribute__ being dropped after del Base.__getattr__ - #9800
Draft
youknowone with Copilot wants to merge 2 commits into
Draft
youknowone with Copilot wants to merge 2 commits into
youknowone with Copilot wants to merge 2 commits into
Conversation
Contributor
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
Co-authored-by: youknowone <69878+youknowone@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix subclass __getattribute__ not being called after deleting __getattr__
Fix subclass Nov 11, 2026
__getattribute__ being dropped after del Base.__getattr__
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
__getattribute__and__getattr__share the getattro slot. When one of them was removed from a class, the slot update re-inherited from the first base with a getattro slot. It never looked at a__getattribute__in the class's own dict, so a subclass's override was silently lost. This is what happens to subclasses aftermock.patch.object(Base, "__getattr__", ..., create=True)exits.Changes
crates/vm/src/types/slot.rs(SlotAccessor::TpGetattro): when no__getattr__is in the MRO, always resolve the slot throughlookup_slot_in_mroon__getattribute__, for both add and remove. Previously this happened only on add, and it used the changed name rather than__getattribute__. Theinherit_from_mrofallback on removal is gone, so this now matches howTpSetattroresolves__setattr__/__delattr__.extra_tests/snippets/builtin_object.py: regression test for the add-then-delete sequence above.__getattr__from a base class stops a subclass's own__getattribute__from being called #9796