Repository navigation
Fix subclass __getattribute__ being dropped after del Base.__getattr__ - #9800
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
__getattribute__ being dropped after del Base.__getattr__
Co-authored-by: youknowone <[email protected]>
update_slot for TpGetattro now looks up __getattribute__ and __getattr__ through the MRO on both add and remove, and picks the slot from the pair the same way TpSetattro does for __setattr__/__delattr__. Assisted-by: Claude:claude-opus-5-5
8cc118f to
e4e2305
Compare
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
__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): on both add and remove, look up__getattribute__and__getattr__through the MRO and pick the slot from the pair, in the same wayTpSetattroresolves__setattr__/__delattr__:getattro_wrapper__getattr__has no native wrapper descriptor, so finding it anywhere in the MRO always selectsgetattro_wrapper. Previously the slot was re-resolved only on add, and removal always fell back toinherit_from_mro.extra_tests/snippets/builtin_object.py: regression test for the add-then-delete sequence above.Fixes Deleting
__getattr__from a base class stops a subclass's own__getattribute__from being called #9796