Skip to content

Commit aa18896

Browse files
committed
Add parent_payload to instance.
1 parent 03b4199 commit aa18896

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

vm/src/obj/objtype.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ pub fn get_attributes(obj: &PyObjectRef) -> PyAttributes {
272272
}
273273

274274
// Get instance attributes:
275-
if let PyObjectPayload::Instance { dict } = &obj.payload {
275+
if let PyObjectPayload::Instance { dict, .. } = &obj.payload {
276276
for (name, value) in dict.borrow().iter() {
277277
attributes.insert(name.to_string(), value.clone());
278278
}

vm/src/pyobject.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ impl PyContext {
661661
PyObject::new(
662662
PyObjectPayload::Instance {
663663
dict: RefCell::new(dict),
664+
parent_payload: None,
664665
},
665666
class,
666667
)
@@ -688,7 +689,8 @@ impl PyContext {
688689
PyObjectPayload::Module { ref scope, .. } => {
689690
scope.locals.set_item(self, attr_name, value)
690691
}
691-
PyObjectPayload::Instance { ref dict } | PyObjectPayload::Class { ref dict, .. } => {
692+
PyObjectPayload::Instance { ref dict, .. }
693+
| PyObjectPayload::Class { ref dict, .. } => {
692694
dict.borrow_mut().insert(attr_name.to_string(), value);
693695
}
694696
ref payload => unimplemented!("set_attr unimplemented for: {:?}", payload),
@@ -804,7 +806,7 @@ impl AttributeProtocol for PyObjectRef {
804806
}
805807
None
806808
}
807-
PyObjectPayload::Instance { ref dict } => dict.borrow().get(attr_name).cloned(),
809+
PyObjectPayload::Instance { ref dict, .. } => dict.borrow().get(attr_name).cloned(),
808810
_ => None,
809811
}
810812
}
@@ -815,7 +817,7 @@ impl AttributeProtocol for PyObjectRef {
815817
PyObjectPayload::Class { ref mro, .. } => {
816818
class_has_item(self, attr_name) || mro.iter().any(|d| class_has_item(d, attr_name))
817819
}
818-
PyObjectPayload::Instance { ref dict } => dict.borrow().contains_key(attr_name),
820+
PyObjectPayload::Instance { ref dict, .. } => dict.borrow().contains_key(attr_name),
819821
_ => false,
820822
}
821823
}
@@ -1496,6 +1498,7 @@ pub enum PyObjectPayload {
14961498
},
14971499
Instance {
14981500
dict: RefCell<PyAttributes>,
1501+
parent_payload: Option<Box<PyObjectPayload>>,
14991502
},
15001503
RustFunction {
15011504
function: PyNativeFunc,

0 commit comments

Comments
 (0)