Skip to content

Commit 3cc6d97

Browse files
committed
cleanup
1 parent bf2bde1 commit 3cc6d97

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

vm/src/builtins/super.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ impl Initializer for PySuper {
125125
(typ, obj)
126126
};
127127

128-
let mut inner = PySuperInner::new(typ, obj, vm)?;
129-
std::mem::swap(&mut inner, &mut zelf.inner.write());
128+
let inner = PySuperInner::new(typ, obj, vm)?;
129+
let _ = std::mem::replace::<PySuperInner>(&mut zelf.inner.write(), inner);
130130

131131
Ok(())
132132
}
@@ -173,14 +173,19 @@ impl GetAttr for PySuper {
173173
.skip(1) // skip su->type (if any)
174174
.collect();
175175
for cls in mro.iter() {
176+
println!("traversing mro: {}", cls.name());
176177
if let Some(descr) = cls.get_direct_attr(name) {
178+
// Only pass 'obj' param if this is instance-mode super (See https://bugs.python.org/issue743267)
179+
let obj = if obj.is(&start_type) {
180+
None
181+
} else {
182+
println!("getattr {}.{} as {}", obj.class().name(), name, cls.name());
183+
184+
Some(obj)
185+
};
186+
let cls = cls.as_object().to_owned();
177187
return vm
178-
.call_get_descriptor_specific(
179-
&descr,
180-
// Only pass 'obj' param if this is instance-mode super (See https://bugs.python.org/issue743267)
181-
if obj.is(&start_type) { None } else { Some(obj) },
182-
Some(start_type.as_object().to_owned()),
183-
)
188+
.call_get_descriptor_specific(&descr, obj, Some(cls))
184189
.unwrap_or(Ok(descr));
185190
}
186191
}

0 commit comments

Comments
 (0)