diff --git a/stdlib/src/array.rs b/stdlib/src/array.rs index 26f5cd39f..d05073ef1 100644 --- a/stdlib/src/array.rs +++ b/stdlib/src/array.rs @@ -1,4 +1,31 @@ -pub(crate) use array::make_module; +use rustpython_vm::{PyObjectRef, VirtualMachine}; + +pub(crate) fn make_module(vm: &VirtualMachine) -> PyObjectRef { + let module = array::make_module(vm); + + let array = module + .get_attr("array", vm) + .expect("Expect array has arrat type."); + + // TODO: RUSTPYTHON + // FIXME: it should import 'collections.abc' instead of '_collection_abc' + let collections_abc = vm + .import("_collections_abc", None, 0) + .expect("Expect collections.abc exist."); + let mutable_sequence = collections_abc + .get_attr("MutableSequence", vm) + .expect("Expect collections.abc has MutableSequence type."); + + vm.invoke( + &mutable_sequence + .get_attr("register", vm) + .expect("Expect collections.abc.MutableSequence has register method."), + (array,), + ) + .expect("Expect collections.abc.MutableSequence.register(array.array) not fail."); + + module +} #[pymodule(name = "array")] mod array {