GeezerVison is showing github.com — Fix subclass `__getattribute__` being dropped after `del Base.__getattr__` by Copilot · Pull Request #9800 · RustPython/RustPython
Conversation
Copilot
AI
commented
Nov 11, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
__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 after mock.patch.object(Base, "__getattr__", ..., create=True) exits.
class Base: pass
class Proxy(Base):
def __getattribute__(self, name):
print("Proxy.__getattribute__", name)
return object.__getattribute__(self, name)
p = Proxy(); p.x = 1
Base.__getattr__ = lambda self, name: "fallback"
del Base.__getattr__
p.x # CPython: calls Proxy.__getattribute__; RustPython (before): skipped it
Changes
crates/vm/src/types/slot.rs (SlotAccessor::TpGetattro): when no __getattr__ is in the MRO, always resolve the slot through lookup_slot_in_mro on __getattribute__, for both add and remove. Previously this happened only on add, and it used the changed name rather than __getattribute__. The inherit_from_mro fallback on removal is gone, so this now matches how TpSetattro resolves __setattr__/__delattr__.
extra_tests/snippets/builtin_object.py: regression test for the add-then-delete sequence above.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Nov 11, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Important
Review skipped
Bot user detected.
To trigger a single review, invoke the @coderabbitai review command.
Run configuration
-
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
-
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Copilot
AI
changed the title
[WIP] Fix subclass __getattribute__ not being called after deleting __getattr__
Fix subclass __getattribute__ being dropped after del Base.__getattr__
Nov 11, 2026
Reviewers
youknowone
Awaiting requested review from youknowone
At least 1 approving review is required to merge this pull request.
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
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.
|