From 32d2406fa8bd891cd88aa511eb183d5b3d17d1c5 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Fri, 16 Jan 2026 10:51:18 +0900 Subject: [PATCH] module_def --- crates/derive-impl/src/pymodule.rs | 4 +- crates/stdlib/src/binascii.rs | 2 +- crates/stdlib/src/bisect.rs | 2 +- crates/stdlib/src/blake2.rs | 2 +- crates/stdlib/src/bz2.rs | 2 +- crates/stdlib/src/cmath.rs | 2 +- crates/stdlib/src/csv.rs | 2 +- crates/stdlib/src/faulthandler.rs | 2 +- crates/stdlib/src/fcntl.rs | 2 +- crates/stdlib/src/gc.rs | 14 +- crates/stdlib/src/grp.rs | 2 +- crates/stdlib/src/hashlib.rs | 2 +- crates/stdlib/src/json.rs | 2 +- crates/stdlib/src/lib.rs | 192 +++++++++++++++------------ crates/stdlib/src/locale.rs | 2 +- crates/stdlib/src/lzma.rs | 2 +- crates/stdlib/src/math.rs | 2 +- crates/stdlib/src/md5.rs | 2 +- crates/stdlib/src/mmap.rs | 2 +- crates/stdlib/src/multiprocessing.rs | 2 +- crates/stdlib/src/opcode.rs | 2 +- crates/stdlib/src/overlapped.rs | 2 +- crates/stdlib/src/posixshmem.rs | 2 +- crates/stdlib/src/posixsubprocess.rs | 2 +- crates/stdlib/src/pystruct.rs | 2 +- crates/stdlib/src/random.rs | 2 +- crates/stdlib/src/re.rs | 2 +- crates/stdlib/src/resource.rs | 2 +- crates/stdlib/src/scproxy.rs | 2 +- crates/stdlib/src/sha1.rs | 2 +- crates/stdlib/src/sha3.rs | 2 +- crates/stdlib/src/ssl.rs | 2 +- crates/stdlib/src/statistics.rs | 2 +- crates/stdlib/src/suggestions.rs | 2 +- crates/stdlib/src/syslog.rs | 2 +- crates/stdlib/src/termios.rs | 2 +- crates/stdlib/src/tkinter.rs | 2 +- crates/stdlib/src/uuid.rs | 2 +- crates/stdlib/src/zlib.rs | 2 +- crates/vm/src/stdlib/builtins.rs | 2 +- crates/vm/src/stdlib/sys.rs | 4 +- crates/vm/src/vm/mod.rs | 4 +- 42 files changed, 155 insertions(+), 137 deletions(-) diff --git a/crates/derive-impl/src/pymodule.rs b/crates/derive-impl/src/pymodule.rs index 3689ac97f..ebcea89ac 100644 --- a/crates/derive-impl/src/pymodule.rs +++ b/crates/derive-impl/src/pymodule.rs @@ -123,7 +123,7 @@ pub fn impl_pymodule(attr: PunctuatedNestedMeta, module_item: Item) -> Result = #doc; }, parse_quote! { - pub(crate) fn __module_def( + pub(crate) fn module_def( ctx: &::rustpython_vm::Context, ) -> &'static ::rustpython_vm::builtins::PyModuleDef { DEF.get_or_init(|| { @@ -144,7 +144,7 @@ pub fn impl_pymodule(attr: PunctuatedNestedMeta, module_item: Item) -> Result ::rustpython_vm::PyRef<::rustpython_vm::builtins::PyModule> { use ::rustpython_vm::PyPayload; - let module = ::rustpython_vm::builtins::PyModule::from_def(__module_def(&vm.ctx)).into_ref(&vm.ctx); + let module = ::rustpython_vm::builtins::PyModule::from_def(module_def(&vm.ctx)).into_ref(&vm.ctx); __init_dict(vm, &module); extend_module(vm, &module).unwrap(); module diff --git a/crates/stdlib/src/binascii.rs b/crates/stdlib/src/binascii.rs index 671d1d9e2..ee55d482e 100644 --- a/crates/stdlib/src/binascii.rs +++ b/crates/stdlib/src/binascii.rs @@ -1,7 +1,7 @@ // spell-checker:ignore hexlify unhexlify uuencodes CRCTAB rlecode rledecode pub(super) use decl::crc32; -pub(crate) use decl::make_module; +pub(crate) use decl::module_def; use rustpython_vm::{VirtualMachine, builtins::PyBaseExceptionRef, convert::ToPyException}; const PAD: u8 = 61u8; diff --git a/crates/stdlib/src/bisect.rs b/crates/stdlib/src/bisect.rs index e712d0275..69b6e8aee 100644 --- a/crates/stdlib/src/bisect.rs +++ b/crates/stdlib/src/bisect.rs @@ -1,4 +1,4 @@ -pub(crate) use _bisect::make_module; +pub(crate) use _bisect::module_def; #[pymodule] mod _bisect { diff --git a/crates/stdlib/src/blake2.rs b/crates/stdlib/src/blake2.rs index 4209c966e..5d2e991b9 100644 --- a/crates/stdlib/src/blake2.rs +++ b/crates/stdlib/src/blake2.rs @@ -1,6 +1,6 @@ // spell-checker:ignore usedforsecurity HASHXOF -pub(crate) use _blake2::make_module; +pub(crate) use _blake2::module_def; #[pymodule] mod _blake2 { diff --git a/crates/stdlib/src/bz2.rs b/crates/stdlib/src/bz2.rs index 93142e92a..575f33c4b 100644 --- a/crates/stdlib/src/bz2.rs +++ b/crates/stdlib/src/bz2.rs @@ -1,6 +1,6 @@ // spell-checker:ignore compresslevel -pub(crate) use _bz2::make_module; +pub(crate) use _bz2::module_def; #[pymodule] mod _bz2 { diff --git a/crates/stdlib/src/cmath.rs b/crates/stdlib/src/cmath.rs index e7abb3bca..e7ea317d2 100644 --- a/crates/stdlib/src/cmath.rs +++ b/crates/stdlib/src/cmath.rs @@ -1,4 +1,4 @@ -pub(crate) use cmath::make_module; +pub(crate) use cmath::module_def; #[pymodule] mod cmath { diff --git a/crates/stdlib/src/csv.rs b/crates/stdlib/src/csv.rs index 4f6cbd768..7c89ebbba 100644 --- a/crates/stdlib/src/csv.rs +++ b/crates/stdlib/src/csv.rs @@ -1,4 +1,4 @@ -pub(crate) use _csv::make_module; +pub(crate) use _csv::module_def; #[pymodule] mod _csv { diff --git a/crates/stdlib/src/faulthandler.rs b/crates/stdlib/src/faulthandler.rs index 35238367f..cb8d47fb6 100644 --- a/crates/stdlib/src/faulthandler.rs +++ b/crates/stdlib/src/faulthandler.rs @@ -1,4 +1,4 @@ -pub(crate) use decl::make_module; +pub(crate) use decl::module_def; #[allow(static_mut_refs)] // TODO: group code only with static mut refs #[pymodule(name = "faulthandler")] diff --git a/crates/stdlib/src/fcntl.rs b/crates/stdlib/src/fcntl.rs index 477c1f542..407a2dfd6 100644 --- a/crates/stdlib/src/fcntl.rs +++ b/crates/stdlib/src/fcntl.rs @@ -1,6 +1,6 @@ // spell-checker:disable -pub(crate) use fcntl::make_module; +pub(crate) use fcntl::module_def; #[pymodule] mod fcntl { diff --git a/crates/stdlib/src/gc.rs b/crates/stdlib/src/gc.rs index 5fc96a302..36a77db85 100644 --- a/crates/stdlib/src/gc.rs +++ b/crates/stdlib/src/gc.rs @@ -1,8 +1,8 @@ -pub(crate) use gc::make_module; +pub(crate) use gc::module_def; #[pymodule] mod gc { - use crate::vm::{PyResult, VirtualMachine, function::FuncArgs}; + use crate::vm::{PyObjectRef, PyResult, VirtualMachine, function::FuncArgs}; #[pyfunction] fn collect(_args: FuncArgs, _vm: &VirtualMachine) -> i32 { @@ -40,13 +40,15 @@ mod gc { } #[pyfunction] - fn get_referents(_args: FuncArgs, vm: &VirtualMachine) -> PyResult { - Err(vm.new_not_implemented_error("")) + fn get_referents(_args: FuncArgs, vm: &VirtualMachine) -> PyObjectRef { + // RustPython does not track object references. + vm.ctx.new_tuple(vec![]).into() } #[pyfunction] - fn get_referrers(_args: FuncArgs, vm: &VirtualMachine) -> PyResult { - Err(vm.new_not_implemented_error("")) + fn get_referrers(_args: FuncArgs, vm: &VirtualMachine) -> PyObjectRef { + // RustPython does not track object references. + vm.ctx.new_list(vec![]).into() } #[pyfunction] diff --git a/crates/stdlib/src/grp.rs b/crates/stdlib/src/grp.rs index 9f7e41955..c1a52eee6 100644 --- a/crates/stdlib/src/grp.rs +++ b/crates/stdlib/src/grp.rs @@ -1,5 +1,5 @@ // spell-checker:disable -pub(crate) use grp::make_module; +pub(crate) use grp::module_def; #[pymodule] mod grp { diff --git a/crates/stdlib/src/hashlib.rs b/crates/stdlib/src/hashlib.rs index 261663c85..c9902eff6 100644 --- a/crates/stdlib/src/hashlib.rs +++ b/crates/stdlib/src/hashlib.rs @@ -1,6 +1,6 @@ // spell-checker:ignore usedforsecurity HASHXOF -pub(crate) use _hashlib::make_module; +pub(crate) use _hashlib::module_def; #[pymodule] pub mod _hashlib { diff --git a/crates/stdlib/src/json.rs b/crates/stdlib/src/json.rs index 4bdf45335..3baeba629 100644 --- a/crates/stdlib/src/json.rs +++ b/crates/stdlib/src/json.rs @@ -1,4 +1,4 @@ -pub(crate) use _json::make_module; +pub(crate) use _json::module_def; mod machinery; #[pymodule] diff --git a/crates/stdlib/src/lib.rs b/crates/stdlib/src/lib.rs index bc601de19..043176e68 100644 --- a/crates/stdlib/src/lib.rs +++ b/crates/stdlib/src/lib.rs @@ -115,13 +115,112 @@ use alloc::borrow::Cow; /// These modules are added to sys.modules BEFORE their exec function runs, /// allowing safe circular imports. pub fn get_module_defs() -> impl Iterator, StdlibDefFunc)> { - [( - Cow::from("_asyncio"), - _asyncio::__module_def as StdlibDefFunc, - )] - .into_iter() + macro_rules! modules { + { + $( + #[cfg($cfg:meta)] + { $( $key:expr => $val:expr),* $(,)? } + )* + } => {{ + [ + $( + $(#[cfg($cfg)] (Cow::<'static, str>::from($key), $val as StdlibDefFunc),)* + )* + ] + .into_iter() + }}; + } + modules! { + #[cfg(all())] + { + "_asyncio" => _asyncio::module_def, + "binascii" => binascii::module_def, + "_bisect" => bisect::module_def, + "_blake2" => blake2::module_def, + "_bz2" => bz2::module_def, + "cmath" => cmath::module_def, + "_csv" => csv::module_def, + "faulthandler" => faulthandler::module_def, + "gc" => gc::module_def, + "_hashlib" => hashlib::module_def, + "_json" => json::module_def, + "math" => math::module_def, + "_md5" => md5::module_def, + "_opcode" => opcode::module_def, + "_random" => random::module_def, + "_sha1" => sha1::module_def, + "_sha3" => sha3::module_def, + "_statistics" => statistics::module_def, + "_struct" => pystruct::module_def, + "_suggestions" => suggestions::module_def, + "zlib" => zlib::module_def, + } + #[cfg(any(unix, target_os = "wasi"))] + { + "fcntl" => fcntl::module_def, + } + #[cfg(not(target_arch = "wasm32"))] + { + "_multiprocessing" => multiprocessing::module_def, + } + #[cfg(not(any(target_os = "android", target_arch = "wasm32")))] + { + "_lzma" => lzma::module_def, + } + #[cfg(all(not(target_arch = "wasm32"), feature = "ssl-rustls"))] + { + "_ssl" => ssl::module_def, + } + #[cfg(windows)] + { + "_overlapped" => overlapped::module_def, + } + #[cfg(unix)] + { + "_posixsubprocess" => posixsubprocess::module_def, + } + #[cfg(all(unix, not(target_os = "redox"), not(target_os = "android")))] + { + "_posixshmem" => posixshmem::module_def, + } + #[cfg(any(unix, windows))] + { + "mmap" => mmap::module_def, + } + #[cfg(all(unix, not(target_os = "redox")))] + { + "syslog" => syslog::module_def, + "resource" => resource::module_def, + } + #[cfg(all(unix, not(any(target_os = "ios", target_os = "redox"))))] + { + "termios" => termios::module_def, + } + #[cfg(all(unix, not(any(target_os = "android", target_os = "redox"))))] + { + "grp" => grp::module_def, + } + #[cfg(target_os = "macos")] + { + "_scproxy" => scproxy::module_def, + } + #[cfg(not(any(target_os = "android", target_os = "ios", target_os = "windows", target_arch = "wasm32", target_os = "redox")))] + { + "_uuid" => uuid::module_def, + } + #[cfg(not(any(target_os = "ios", target_arch = "wasm32")))] + { + "_locale" => locale::module_def, + } + #[cfg(feature = "tkinter")] + { + "_tkinter" => tkinter::module_def, + } + } } +/// Returns module initializers for single-phase init modules. +/// These are modules that don't use #[pymodule] macro or need custom initialization. pub fn get_module_inits() -> impl Iterator, StdlibInitFunc)> { macro_rules! modules { { @@ -142,37 +241,11 @@ pub fn get_module_inits() -> impl Iterator, StdlibInit #[cfg(all())] { "array" => array::make_module, - "binascii" => binascii::make_module, - "_bisect" => bisect::make_module, - "_bz2" => bz2::make_module, - "cmath" => cmath::make_module, "_contextvars" => contextvars::make_module, - "_csv" => csv::make_module, - "faulthandler" => faulthandler::make_module, - "gc" => gc::make_module, - "_hashlib" => hashlib::make_module, - "_sha1" => sha1::make_module, - "_sha3" => sha3::make_module, + "pyexpat" => pyexpat::make_module, "_sha256" => sha256::make_module, "_sha512" => sha512::make_module, - "_md5" => md5::make_module, - "_blake2" => blake2::make_module, - "_json" => json::make_module, - "math" => math::make_module, - "pyexpat" => pyexpat::make_module, - "_opcode" => opcode::make_module, - "_random" => random::make_module, - "_statistics" => statistics::make_module, - "_struct" => pystruct::make_module, "unicodedata" => unicodedata::make_module, - "zlib" => zlib::make_module, - "_statistics" => statistics::make_module, - "_suggestions" => suggestions::make_module, - // crate::vm::sysmodule::sysconfigdata_name() => sysconfigdata::make_module, - } - #[cfg(any(unix, target_os = "wasi"))] - { - "fcntl" => fcntl::make_module, } #[cfg(any(unix, windows, target_os = "wasi"))] { @@ -180,70 +253,15 @@ pub fn get_module_inits() -> impl Iterator, StdlibInit } #[cfg(not(target_arch = "wasm32"))] { - "_multiprocessing" => multiprocessing::make_module, "_socket" => socket::make_module, } - #[cfg(not(any(target_os = "android", target_arch = "wasm32")))] - { - "_lzma" => lzma::make_module, - } #[cfg(all(feature = "sqlite", not(any(target_os = "android", target_arch = "wasm32"))))] { "_sqlite3" => sqlite::make_module, } - #[cfg(all(not(target_arch = "wasm32"), feature = "ssl-rustls"))] - { - "_ssl" => ssl::make_module, - } #[cfg(all(not(target_arch = "wasm32"), feature = "ssl-openssl"))] { "_ssl" => openssl::make_module, } - #[cfg(windows)] - { - "_overlapped" => overlapped::make_module, - } - // Unix-only - #[cfg(unix)] - { - "_posixsubprocess" => posixsubprocess::make_module, - } - #[cfg(all(unix, not(target_os = "redox"), not(target_os = "android")))] - { - "_posixshmem" => posixshmem::make_module, - } - #[cfg(any(unix, windows))] - { - "mmap" => mmap::make_module, - } - #[cfg(all(unix, not(target_os = "redox")))] - { - "syslog" => syslog::make_module, - "resource" => resource::make_module, - } - #[cfg(all(unix, not(any(target_os = "ios", target_os = "redox"))))] - { - "termios" => termios::make_module, - } - #[cfg(all(unix, not(any(target_os = "android", target_os = "redox"))))] - { - "grp" => grp::make_module, - } - #[cfg(target_os = "macos")] - { - "_scproxy" => scproxy::make_module, - } - #[cfg(not(any(target_os = "android", target_os = "ios", target_os = "windows", target_arch = "wasm32", target_os = "redox")))] - { - "_uuid" => uuid::make_module, - } - #[cfg(not(any(target_os = "ios", target_arch = "wasm32")))] - { - "_locale" => locale::make_module, - } - #[cfg(feature = "tkinter")] - { - "_tkinter" => tkinter::make_module, - } } } diff --git a/crates/stdlib/src/locale.rs b/crates/stdlib/src/locale.rs index 51cf35259..98db77d0d 100644 --- a/crates/stdlib/src/locale.rs +++ b/crates/stdlib/src/locale.rs @@ -1,6 +1,6 @@ // spell-checker:ignore abday abmon yesexpr noexpr CRNCYSTR RADIXCHAR AMPM THOUSEP -pub(crate) use _locale::make_module; +pub(crate) use _locale::module_def; #[cfg(windows)] #[repr(C)] diff --git a/crates/stdlib/src/lzma.rs b/crates/stdlib/src/lzma.rs index b18ac3ee6..0189c9d2e 100644 --- a/crates/stdlib/src/lzma.rs +++ b/crates/stdlib/src/lzma.rs @@ -1,6 +1,6 @@ // spell-checker:ignore ARMTHUMB -pub(crate) use _lzma::make_module; +pub(crate) use _lzma::module_def; #[pymodule] mod _lzma { diff --git a/crates/stdlib/src/math.rs b/crates/stdlib/src/math.rs index 1e014e49e..e72fc7990 100644 --- a/crates/stdlib/src/math.rs +++ b/crates/stdlib/src/math.rs @@ -1,4 +1,4 @@ -pub(crate) use math::make_module; +pub(crate) use math::__module_def; use crate::vm::{VirtualMachine, builtins::PyBaseExceptionRef}; diff --git a/crates/stdlib/src/md5.rs b/crates/stdlib/src/md5.rs index dca48242b..11923b165 100644 --- a/crates/stdlib/src/md5.rs +++ b/crates/stdlib/src/md5.rs @@ -1,4 +1,4 @@ -pub(crate) use _md5::make_module; +pub(crate) use _md5::module_def; #[pymodule] mod _md5 { diff --git a/crates/stdlib/src/mmap.rs b/crates/stdlib/src/mmap.rs index d38955210..625b6db5f 100644 --- a/crates/stdlib/src/mmap.rs +++ b/crates/stdlib/src/mmap.rs @@ -1,6 +1,6 @@ // spell-checker:disable //! mmap module -pub(crate) use mmap::make_module; +pub(crate) use mmap::module_def; #[pymodule] mod mmap { diff --git a/crates/stdlib/src/multiprocessing.rs b/crates/stdlib/src/multiprocessing.rs index bda13e619..f3a7831de 100644 --- a/crates/stdlib/src/multiprocessing.rs +++ b/crates/stdlib/src/multiprocessing.rs @@ -1,4 +1,4 @@ -pub(crate) use _multiprocessing::make_module; +pub(crate) use _multiprocessing::module_def; #[cfg(windows)] #[pymodule] diff --git a/crates/stdlib/src/opcode.rs b/crates/stdlib/src/opcode.rs index 2563dd717..4f59a3358 100644 --- a/crates/stdlib/src/opcode.rs +++ b/crates/stdlib/src/opcode.rs @@ -1,4 +1,4 @@ -pub(crate) use opcode::make_module; +pub(crate) use opcode::__module_def; #[pymodule] mod opcode { diff --git a/crates/stdlib/src/overlapped.rs b/crates/stdlib/src/overlapped.rs index 664aa3f39..b591a2f0f 100644 --- a/crates/stdlib/src/overlapped.rs +++ b/crates/stdlib/src/overlapped.rs @@ -1,6 +1,6 @@ // spell-checker:disable -pub(crate) use _overlapped::make_module; +pub(crate) use _overlapped::module_def; #[allow(non_snake_case)] #[pymodule] diff --git a/crates/stdlib/src/posixshmem.rs b/crates/stdlib/src/posixshmem.rs index a52866b79..2a142d8b6 100644 --- a/crates/stdlib/src/posixshmem.rs +++ b/crates/stdlib/src/posixshmem.rs @@ -1,5 +1,5 @@ #[cfg(all(unix, not(target_os = "redox"), not(target_os = "android")))] -pub(crate) use _posixshmem::make_module; +pub(crate) use _posixshmem::module_def; #[cfg(all(unix, not(target_os = "redox"), not(target_os = "android")))] #[pymodule] diff --git a/crates/stdlib/src/posixsubprocess.rs b/crates/stdlib/src/posixsubprocess.rs index a6badc081..3d5e4c356 100644 --- a/crates/stdlib/src/posixsubprocess.rs +++ b/crates/stdlib/src/posixsubprocess.rs @@ -22,7 +22,7 @@ use alloc::ffi::CString; use core::{convert::Infallible as Never, ffi::CStr, marker::PhantomData, ops::Deref}; -pub(crate) use _posixsubprocess::make_module; +pub(crate) use _posixsubprocess::module_def; #[pymodule] mod _posixsubprocess { diff --git a/crates/stdlib/src/pystruct.rs b/crates/stdlib/src/pystruct.rs index 8801f0d70..d3be417ed 100644 --- a/crates/stdlib/src/pystruct.rs +++ b/crates/stdlib/src/pystruct.rs @@ -5,7 +5,7 @@ //! Use this rust module to do byte packing: //! -pub(crate) use _struct::make_module; +pub(crate) use _struct::module_def; #[pymodule] pub(crate) mod _struct { diff --git a/crates/stdlib/src/random.rs b/crates/stdlib/src/random.rs index be31d3011..35e6473d8 100644 --- a/crates/stdlib/src/random.rs +++ b/crates/stdlib/src/random.rs @@ -1,6 +1,6 @@ //! Random module. -pub(crate) use _random::make_module; +pub(crate) use _random::module_def; #[pymodule] mod _random { diff --git a/crates/stdlib/src/re.rs b/crates/stdlib/src/re.rs index 5af456715..fdb14d427 100644 --- a/crates/stdlib/src/re.rs +++ b/crates/stdlib/src/re.rs @@ -1,4 +1,4 @@ -pub(crate) use re::make_module; +pub(crate) use re::module_def; #[pymodule] mod re { diff --git a/crates/stdlib/src/resource.rs b/crates/stdlib/src/resource.rs index e6df75e4b..34c8161e0 100644 --- a/crates/stdlib/src/resource.rs +++ b/crates/stdlib/src/resource.rs @@ -1,6 +1,6 @@ // spell-checker:disable -pub(crate) use resource::make_module; +pub(crate) use resource::module_def; #[pymodule] mod resource { diff --git a/crates/stdlib/src/scproxy.rs b/crates/stdlib/src/scproxy.rs index b105dc4f2..09e7cdc60 100644 --- a/crates/stdlib/src/scproxy.rs +++ b/crates/stdlib/src/scproxy.rs @@ -1,4 +1,4 @@ -pub(crate) use _scproxy::make_module; +pub(crate) use _scproxy::module_def; #[pymodule] mod _scproxy { diff --git a/crates/stdlib/src/sha1.rs b/crates/stdlib/src/sha1.rs index 04845bb76..28d4bcbbe 100644 --- a/crates/stdlib/src/sha1.rs +++ b/crates/stdlib/src/sha1.rs @@ -1,4 +1,4 @@ -pub(crate) use _sha1::make_module; +pub(crate) use _sha1::module_def; #[pymodule] mod _sha1 { diff --git a/crates/stdlib/src/sha3.rs b/crates/stdlib/src/sha3.rs index 07b61d9ae..e7342d0dd 100644 --- a/crates/stdlib/src/sha3.rs +++ b/crates/stdlib/src/sha3.rs @@ -1,4 +1,4 @@ -pub(crate) use _sha3::make_module; +pub(crate) use _sha3::module_def; #[pymodule] mod _sha3 { diff --git a/crates/stdlib/src/ssl.rs b/crates/stdlib/src/ssl.rs index 959525d1f..7d27e259c 100644 --- a/crates/stdlib/src/ssl.rs +++ b/crates/stdlib/src/ssl.rs @@ -25,7 +25,7 @@ mod compat; // SSL exception types (shared with openssl backend) mod error; -pub(crate) use _ssl::make_module; +pub(crate) use _ssl::module_def; #[allow(non_snake_case)] #[allow(non_upper_case_globals)] diff --git a/crates/stdlib/src/statistics.rs b/crates/stdlib/src/statistics.rs index 8be2447ff..641d8864e 100644 --- a/crates/stdlib/src/statistics.rs +++ b/crates/stdlib/src/statistics.rs @@ -1,4 +1,4 @@ -pub(crate) use _statistics::make_module; +pub(crate) use _statistics::module_def; #[pymodule] mod _statistics { diff --git a/crates/stdlib/src/suggestions.rs b/crates/stdlib/src/suggestions.rs index e49e9dd4a..e0667dfb5 100644 --- a/crates/stdlib/src/suggestions.rs +++ b/crates/stdlib/src/suggestions.rs @@ -1,4 +1,4 @@ -pub(crate) use _suggestions::make_module; +pub(crate) use _suggestions::module_def; #[pymodule] mod _suggestions { diff --git a/crates/stdlib/src/syslog.rs b/crates/stdlib/src/syslog.rs index b52d14156..8f446a8e1 100644 --- a/crates/stdlib/src/syslog.rs +++ b/crates/stdlib/src/syslog.rs @@ -1,6 +1,6 @@ // spell-checker:ignore logoption openlog setlogmask upto NDELAY ODELAY -pub(crate) use syslog::make_module; +pub(crate) use syslog::module_def; #[pymodule(name = "syslog")] mod syslog { diff --git a/crates/stdlib/src/termios.rs b/crates/stdlib/src/termios.rs index a9ae1375c..48dfae25a 100644 --- a/crates/stdlib/src/termios.rs +++ b/crates/stdlib/src/termios.rs @@ -1,6 +1,6 @@ // spell-checker:disable -pub(crate) use self::termios::make_module; +pub(crate) use self::termios::module_def; #[pymodule] mod termios { diff --git a/crates/stdlib/src/tkinter.rs b/crates/stdlib/src/tkinter.rs index 6b7c4387d..b258002c1 100644 --- a/crates/stdlib/src/tkinter.rs +++ b/crates/stdlib/src/tkinter.rs @@ -1,6 +1,6 @@ // spell-checker:ignore createcommand -pub(crate) use self::_tkinter::make_module; +pub(crate) use self::_tkinter::module_def; #[pymodule] mod _tkinter { diff --git a/crates/stdlib/src/uuid.rs b/crates/stdlib/src/uuid.rs index 3f75db402..3bc01610d 100644 --- a/crates/stdlib/src/uuid.rs +++ b/crates/stdlib/src/uuid.rs @@ -1,4 +1,4 @@ -pub(crate) use _uuid::make_module; +pub(crate) use _uuid::module_def; #[pymodule] mod _uuid { diff --git a/crates/stdlib/src/zlib.rs b/crates/stdlib/src/zlib.rs index 632543c5c..40269f12b 100644 --- a/crates/stdlib/src/zlib.rs +++ b/crates/stdlib/src/zlib.rs @@ -1,6 +1,6 @@ // spell-checker:ignore compressobj decompressobj zdict chunksize zlibmodule miniz chunker -pub(crate) use zlib::make_module; +pub(crate) use zlib::module_def; #[pymodule] mod zlib { diff --git a/crates/vm/src/stdlib/builtins.rs b/crates/vm/src/stdlib/builtins.rs index b4554bc30..7be55261e 100644 --- a/crates/vm/src/stdlib/builtins.rs +++ b/crates/vm/src/stdlib/builtins.rs @@ -2,7 +2,7 @@ //! //! Implements the list of [builtin Python functions](https://docs.python.org/3/library/builtins.html). use crate::{Py, VirtualMachine, builtins::PyModule, class::PyClassImpl}; -pub(crate) use builtins::{__module_def, DOC}; +pub(crate) use builtins::{DOC, module_def}; pub use builtins::{ascii, print, reversed}; #[pymodule] diff --git a/crates/vm/src/stdlib/sys.rs b/crates/vm/src/stdlib/sys.rs index ce10edd58..86eb15810 100644 --- a/crates/vm/src/stdlib/sys.rs +++ b/crates/vm/src/stdlib/sys.rs @@ -1,8 +1,6 @@ use crate::{Py, PyResult, VirtualMachine, builtins::PyModule, convert::ToPyObject}; -pub(crate) use sys::{ - __module_def, DOC, MAXSIZE, RUST_MULTIARCH, UnraisableHookArgsData, multiarch, -}; +pub(crate) use sys::{DOC, MAXSIZE, RUST_MULTIARCH, UnraisableHookArgsData, module_def, multiarch}; #[pymodule(name = "_jit")] mod sys_jit { diff --git a/crates/vm/src/vm/mod.rs b/crates/vm/src/vm/mod.rs index e5c0c7cf5..54def5d75 100644 --- a/crates/vm/src/vm/mod.rs +++ b/crates/vm/src/vm/mod.rs @@ -159,8 +159,8 @@ impl VirtualMachine { }; // Hard-core modules: - let builtins = new_module(stdlib::builtins::__module_def(&ctx)); - let sys_module = new_module(stdlib::sys::__module_def(&ctx)); + let builtins = new_module(stdlib::builtins::module_def(&ctx)); + let sys_module = new_module(stdlib::sys::module_def(&ctx)); let import_func = ctx.none(); let profile_func = RefCell::new(ctx.none());