Skip to content

Commit 2b87143

Browse files
committed
vm: skip LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN when __getattr__ is also defined
Calling __getattribute__ directly bypasses the __getattr__ fallback that slot_tp_getattr_hook normally provides. Guard against this by refusing to specialize when the class also defines __getattr__.
1 parent 52d9164 commit 2b87143

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

crates/vm/src/frame.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6972,6 +6972,7 @@ impl ExecutingFrame<'_> {
69726972
if type_version != 0
69736973
&& !oparg.is_method()
69746974
&& !self.specialization_eval_frame_active(_vm)
6975+
&& cls.get_attr(identifier!(_vm, __getattr__)).is_none()
69756976
&& let Some(getattribute) = cls.get_attr(identifier!(_vm, __getattribute__))
69766977
&& let Some(func) = getattribute.downcast_ref_if_exact::<PyFunction>(_vm)
69776978
&& func.can_specialize_call(2)

0 commit comments

Comments
 (0)