Skip to content

Commit 303f9b9

Browse files
committed
Add (unused) dict element to PyObject struct.
1 parent e0e0734 commit 303f9b9

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

vm/src/pyobject.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,8 @@ pub struct PyContext {
155155
}
156156

157157
fn _nothing() -> PyObjectRef {
158-
PyObject {
159-
payload: PyObjectPayload::AnyRustValue {
160-
value: Box::new(()),
161-
},
162-
typ: None,
163-
}
164-
.into_ref()
158+
let obj: PyObject = Default::default();
159+
obj.into_ref()
165160
}
166161

167162
pub fn create_type(
@@ -745,10 +740,11 @@ impl Default for PyContext {
745740
/// This is an actual python object. It consists of a `typ` which is the
746741
/// python class, and carries some rust payload optionally. This rust
747742
/// payload can be a rust float or rust int in case of float and int objects.
743+
#[derive(Default)]
748744
pub struct PyObject {
749745
pub payload: PyObjectPayload,
750746
pub typ: Option<PyObjectRef>,
751-
// pub dict: HashMap<String, PyObjectRef>, // __dict__ member
747+
pub dict: Option<HashMap<String, PyObjectRef>>, // __dict__ member
752748
}
753749

754750
pub trait IdProtocol {
@@ -1538,6 +1534,14 @@ pub enum PyObjectPayload {
15381534
},
15391535
}
15401536

1537+
impl Default for PyObjectPayload {
1538+
fn default() -> Self {
1539+
PyObjectPayload::AnyRustValue {
1540+
value: Box::new(()),
1541+
}
1542+
}
1543+
}
1544+
15411545
impl fmt::Debug for PyObjectPayload {
15421546
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
15431547
match self {
@@ -1568,14 +1572,11 @@ impl fmt::Debug for PyObjectPayload {
15681572
}
15691573

15701574
impl PyObject {
1571-
pub fn new(
1572-
payload: PyObjectPayload,
1573-
/* dict: PyObjectRef,*/ typ: PyObjectRef,
1574-
) -> PyObjectRef {
1575+
pub fn new(payload: PyObjectPayload, typ: PyObjectRef) -> PyObjectRef {
15751576
PyObject {
15761577
payload,
15771578
typ: Some(typ),
1578-
// dict: HashMap::new(), // dict,
1579+
dict: None,
15791580
}
15801581
.into_ref()
15811582
}

0 commit comments

Comments
 (0)