add missing repr on mappingproxy

Signed-off-by: snowapril <sinjihng@gmail.com>
This commit is contained in:
snowapril
2021-10-02 20:01:14 +09:00
parent 6b1af9a45e
commit fa71ac9699

View File

@@ -137,6 +137,16 @@ impl PyMappingProxy {
}
}
}
#[pymethod(magic)]
fn repr(&self, vm: &VirtualMachine) -> PyResult<String> {
let obj = match &self.mapping {
MappingProxyInner::Dict(d) => d.clone(),
MappingProxyInner::Class(c) => {
PyDict::from_attributes(c.attributes.read().clone(), vm)?.into_pyobject(vm)
}
};
Ok(format!("mappingproxy({})", vm.to_repr(&obj)?))
}
}
impl AsMapping for PyMappingProxy {