Register array.array to collections.abc.MutableSequence

This commit is contained in:
Moreal
2023-01-24 05:55:50 +09:00
parent 685a7e8ac5
commit d0bf163641

View File

@@ -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 {