Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions crates/vm/src/types/slot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1246,8 +1246,8 @@ impl PyType {
if has_getattr {
// Must use wrapper to handle __getattr__
self.slots.getattro.store(Some(getattro_wrapper));
} else if ADD {
match self.lookup_slot_in_mro(name, ctx, |sf| {
} else {
match self.lookup_slot_in_mro(identifier!(ctx, __getattribute__), ctx, |sf| {
if let SlotFunc::GetAttro(f) = sf {
Some(*f)
} else {
Expand All @@ -1264,8 +1264,6 @@ impl PyType {
accessor.inherit_from_mro(self);
}
}
} else {
accessor.inherit_from_mro(self);
}
}
SlotAccessor::TpSetattro => {
Expand Down
15 changes: 15 additions & 0 deletions extra_tests/snippets/builtin_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,18 @@ class MissingSlot:


assert MissingSlot().__getstate__() == (None, {"y": 2})


# deleting __getattr__ from a base must not drop a subclass's __getattribute__
class _GABase:
pass


class _GAProxy(_GABase):
def __getattribute__(self, name):
return "hooked"


_GABase.__getattr__ = lambda self, name: "fallback"
del _GABase.__getattr__
assert _GAProxy().x == "hooked"
Loading