Skip to content

Commit 32d2406

Browse files
committed
module_def
1 parent fee1a4b commit 32d2406

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+135
-117
lines changed

crates/derive-impl/src/pymodule.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ pub fn impl_pymodule(attr: PunctuatedNestedMeta, module_item: Item) -> Result<To
123123
pub(crate) const DOC: Option<&'static str> = #doc;
124124
},
125125
parse_quote! {
126-
pub(crate) fn __module_def(
126+
pub(crate) fn module_def(
127127
ctx: &::rustpython_vm::Context,
128128
) -> &'static ::rustpython_vm::builtins::PyModuleDef {
129129
DEF.get_or_init(|| {
@@ -144,7 +144,7 @@ pub fn impl_pymodule(attr: PunctuatedNestedMeta, module_item: Item) -> Result<To
144144
vm: &::rustpython_vm::VirtualMachine
145145
) -> ::rustpython_vm::PyRef<::rustpython_vm::builtins::PyModule> {
146146
use ::rustpython_vm::PyPayload;
147-
let module = ::rustpython_vm::builtins::PyModule::from_def(__module_def(&vm.ctx)).into_ref(&vm.ctx);
147+
let module = ::rustpython_vm::builtins::PyModule::from_def(module_def(&vm.ctx)).into_ref(&vm.ctx);
148148
__init_dict(vm, &module);
149149
extend_module(vm, &module).unwrap();
150150
module

crates/stdlib/src/binascii.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// spell-checker:ignore hexlify unhexlify uuencodes CRCTAB rlecode rledecode
22

33
pub(super) use decl::crc32;
4-
pub(crate) use decl::make_module;
4+
pub(crate) use decl::module_def;
55
use rustpython_vm::{VirtualMachine, builtins::PyBaseExceptionRef, convert::ToPyException};
66

77
const PAD: u8 = 61u8;

crates/stdlib/src/bisect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pub(crate) use _bisect::make_module;
1+
pub(crate) use _bisect::module_def;
22

33
#[pymodule]
44
mod _bisect {

crates/stdlib/src/blake2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// spell-checker:ignore usedforsecurity HASHXOF
22

3-
pub(crate) use _blake2::make_module;
3+
pub(crate) use _blake2::module_def;
44

55
#[pymodule]
66
mod _blake2 {

crates/stdlib/src/bz2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// spell-checker:ignore compresslevel
22

3-
pub(crate) use _bz2::make_module;
3+
pub(crate) use _bz2::module_def;
44

55
#[pymodule]
66
mod _bz2 {

crates/stdlib/src/cmath.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pub(crate) use cmath::make_module;
1+
pub(crate) use cmath::module_def;
22

33
#[pymodule]
44
mod cmath {

crates/stdlib/src/csv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pub(crate) use _csv::make_module;
1+
pub(crate) use _csv::module_def;
22

33
#[pymodule]
44
mod _csv {

crates/stdlib/src/faulthandler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pub(crate) use decl::make_module;
1+
pub(crate) use decl::module_def;
22

33
#[allow(static_mut_refs)] // TODO: group code only with static mut refs
44
#[pymodule(name = "faulthandler")]

crates/stdlib/src/fcntl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// spell-checker:disable
22

3-
pub(crate) use fcntl::make_module;
3+
pub(crate) use fcntl::module_def;
44

55
#[pymodule]
66
mod fcntl {

crates/stdlib/src/gc.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
pub(crate) use gc::make_module;
1+
pub(crate) use gc::module_def;
22

33
#[pymodule]
44
mod gc {
5-
use crate::vm::{PyResult, VirtualMachine, function::FuncArgs};
5+
use crate::vm::{PyObjectRef, PyResult, VirtualMachine, function::FuncArgs};
66

77
#[pyfunction]
88
fn collect(_args: FuncArgs, _vm: &VirtualMachine) -> i32 {
@@ -40,13 +40,15 @@ mod gc {
4040
}
4141

4242
#[pyfunction]
43-
fn get_referents(_args: FuncArgs, vm: &VirtualMachine) -> PyResult {
44-
Err(vm.new_not_implemented_error(""))
43+
fn get_referents(_args: FuncArgs, vm: &VirtualMachine) -> PyObjectRef {
44+
// RustPython does not track object references.
45+
vm.ctx.new_tuple(vec![]).into()
4546
}
4647

4748
#[pyfunction]
48-
fn get_referrers(_args: FuncArgs, vm: &VirtualMachine) -> PyResult {
49-
Err(vm.new_not_implemented_error(""))
49+
fn get_referrers(_args: FuncArgs, vm: &VirtualMachine) -> PyObjectRef {
50+
// RustPython does not track object references.
51+
vm.ctx.new_list(vec![]).into()
5052
}
5153

5254
#[pyfunction]

0 commit comments

Comments
 (0)