Fix PyNamespace constructor

This commit is contained in:
coolreader18 committed 2019-10-02 20:32:41 -05:00
1 parent 0c84de8a54
commit 7e7a20a653
1 file changed
+5 -3
+5 -3
View File
@@ -11,6 +11,7 @@ use crate::vm::VirtualMachine;
pub struct PyNamespace;
impl PyValue for PyNamespace {
const HAVE_DICT: bool = true;
fn class(vm: &VirtualMachine) -> PyClassRef {
vm.ctx.namespace_type()
}
@@ -18,12 +19,13 @@ impl PyValue for PyNamespace {
#[pyimpl]
impl PyNamespace {
#[pymethod(name = "__init__")]
fn init(zelf: PyRef<Self>, kwargs: KwArgs, vm: &VirtualMachine) -> PyResult<()> {
#[pyslot(new)]
fn tp_new(cls: PyClassRef, kwargs: KwArgs, vm: &VirtualMachine) -> PyResult<PyRef<Self>> {
let zelf = PyNamespace.into_ref_with_type(vm, cls)?;
for (name, value) in kwargs.into_iter() {
vm.set_attr(zelf.as_object(), name, value)?;
}
Ok(())
Ok(zelf)
}
}