mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Register array.array to collections.abc.MutableSequence
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user