diff --git a/crates/stdlib/src/array.rs b/crates/stdlib/src/array.rs index 34dec6f8356..15a64c6d99c 100644 --- a/crates/stdlib/src/array.rs +++ b/crates/stdlib/src/array.rs @@ -35,7 +35,7 @@ mod array { SaturatedSlice, SequenceIndex, SequenceIndexOp, SliceableSequenceMutOp, SliceableSequenceOp, }, - stdlib::warnings, + stdlib::_warnings, types::{ AsBuffer, AsMapping, AsSequence, Comparable, Constructor, IterNext, Iterable, PyComparisonOp, Representable, SelfIter, @@ -647,7 +647,7 @@ mod array { } if spec == 'u' { - warnings::warn( + _warnings::warn( vm.ctx.exceptions.deprecation_warning, "The 'u' type code is deprecated and will be removed in Python 3.16".to_owned(), 1, diff --git a/crates/stdlib/src/faulthandler.rs b/crates/stdlib/src/faulthandler.rs index e717a68e55d..9c4373c312e 100644 --- a/crates/stdlib/src/faulthandler.rs +++ b/crates/stdlib/src/faulthandler.rs @@ -405,7 +405,7 @@ mod decl { // Get all threads' frame stacks from the shared registry #[cfg(feature = "threading")] { - let current_tid = rustpython_vm::stdlib::thread::get_ident(); + let current_tid = rustpython_vm::stdlib::_thread::get_ident(); let registry = vm.state.thread_frames.lock(); // First dump non-current threads, then current thread last diff --git a/crates/stdlib/src/fcntl.rs b/crates/stdlib/src/fcntl.rs index 407a2dfd6b3..0f75a09ba0f 100644 --- a/crates/stdlib/src/fcntl.rs +++ b/crates/stdlib/src/fcntl.rs @@ -8,7 +8,7 @@ mod fcntl { PyResult, VirtualMachine, builtins::PyIntRef, function::{ArgMemoryBuffer, ArgStrOrBytesLike, Either, OptionalArg}, - stdlib::io, + stdlib::_io, }; // TODO: supply these from (please file an issue/PR upstream): @@ -57,7 +57,7 @@ mod fcntl { #[pyfunction] fn fcntl( - io::Fildes(fd): io::Fildes, + _io::Fildes(fd): _io::Fildes, cmd: i32, arg: OptionalArg>, vm: &VirtualMachine, @@ -91,7 +91,7 @@ mod fcntl { #[pyfunction] fn ioctl( - io::Fildes(fd): io::Fildes, + _io::Fildes(fd): _io::Fildes, request: i64, arg: OptionalArg, i32>>, mutate_flag: OptionalArg, @@ -149,7 +149,7 @@ mod fcntl { // XXX: at the time of writing, wasi and redox don't have the necessary constants/function #[cfg(not(any(target_os = "wasi", target_os = "redox")))] #[pyfunction] - fn flock(io::Fildes(fd): io::Fildes, operation: i32, vm: &VirtualMachine) -> PyResult { + fn flock(_io::Fildes(fd): _io::Fildes, operation: i32, vm: &VirtualMachine) -> PyResult { let ret = unsafe { libc::flock(fd, operation) }; // TODO: add support for platforms that don't have a builtin `flock` syscall if ret < 0 { @@ -162,7 +162,7 @@ mod fcntl { #[cfg(not(any(target_os = "wasi", target_os = "redox")))] #[pyfunction] fn lockf( - io::Fildes(fd): io::Fildes, + _io::Fildes(fd): _io::Fildes, cmd: i32, len: OptionalArg, start: OptionalArg, diff --git a/crates/stdlib/src/select.rs b/crates/stdlib/src/select.rs index aeb2271735b..b52144247f7 100644 --- a/crates/stdlib/src/select.rs +++ b/crates/stdlib/src/select.rs @@ -337,7 +337,7 @@ mod decl { common::lock::PyMutex, convert::{IntoPyException, ToPyObject}, function::OptionalArg, - stdlib::io::Fildes, + stdlib::_io::Fildes, }; use core::{convert::TryFrom, time::Duration}; use libc::pollfd; @@ -554,7 +554,7 @@ mod decl { common::lock::{PyRwLock, PyRwLockReadGuard}, convert::{IntoPyException, ToPyObject}, function::OptionalArg, - stdlib::io::Fildes, + stdlib::_io::Fildes, types::Constructor, }; use core::ops::Deref; diff --git a/crates/stdlib/src/ssl.rs b/crates/stdlib/src/ssl.rs index e7a2de0b1ea..399c703faa9 100644 --- a/crates/stdlib/src/ssl.rs +++ b/crates/stdlib/src/ssl.rs @@ -48,7 +48,7 @@ mod _ssl { function::{ ArgBytesLike, ArgMemoryBuffer, Either, FuncArgs, OptionalArg, PyComparisonValue, }, - stdlib::warnings, + stdlib::_warnings, types::{Comparable, Constructor, Hashable, PyComparisonOp, Representable}, }, }; @@ -976,7 +976,7 @@ mod _ssl { // Warn if any deprecated options are being newly set if (set & opt_no) != 0 { - warnings::warn( + _warnings::warn( vm.ctx.exceptions.deprecation_warning, "ssl.OP_NO_SSL*/ssl.OP_NO_TLS* options are deprecated".to_owned(), 2, // stack_level = 2 diff --git a/crates/vm/src/builtins/complex.rs b/crates/vm/src/builtins/complex.rs index 182962a4b2e..b3425d2aac1 100644 --- a/crates/vm/src/builtins/complex.rs +++ b/crates/vm/src/builtins/complex.rs @@ -7,7 +7,7 @@ use crate::{ convert::{IntoPyException, ToPyObject, ToPyResult}, function::{FuncArgs, OptionalArg, PyComparisonValue}, protocol::PyNumberMethods, - stdlib::warnings, + stdlib::_warnings, types::{AsNumber, Comparable, Constructor, Hashable, PyComparisonOp, Representable}, }; use core::cell::Cell; @@ -95,7 +95,7 @@ impl PyObjectRef { let ret_class = result.class().to_owned(); if let Some(ret) = result.downcast_ref::() { - warnings::warn( + _warnings::warn( vm.ctx.exceptions.deprecation_warning, format!( "__complex__ returned non-complex (type {ret_class}). \ diff --git a/crates/vm/src/builtins/genericalias.rs b/crates/vm/src/builtins/genericalias.rs index ecb8728b915..1564229d186 100644 --- a/crates/vm/src/builtins/genericalias.rs +++ b/crates/vm/src/builtins/genericalias.rs @@ -735,7 +735,7 @@ pub fn subscript_generic(type_params: PyObjectRef, vm: &VirtualMachine) -> PyRes PyTuple::new_ref(vec![type_params], &vm.ctx) }; - let args = crate::stdlib::typing::unpack_typevartuples(¶ms, vm)?; + let args = crate::stdlib::_typing::unpack_typevartuples(¶ms, vm)?; generic_alias_class.call((generic_type, args.to_pyobject(vm)), vm) } diff --git a/crates/vm/src/builtins/tuple.rs b/crates/vm/src/builtins/tuple.rs index e1dc1ef306b..623f7144796 100644 --- a/crates/vm/src/builtins/tuple.rs +++ b/crates/vm/src/builtins/tuple.rs @@ -108,7 +108,9 @@ impl PyPayload for PyTuple { #[inline] unsafe fn freelist_push(obj: *mut PyObject) -> bool { - let len = unsafe { &*(obj as *const crate::Py) }.elements.len(); + let len = unsafe { &*(obj as *const crate::Py) } + .elements + .len(); if len == 0 || len > TupleFreeList::MAX_SAVE_SIZE { return false; } diff --git a/crates/vm/src/builtins/union.rs b/crates/vm/src/builtins/union.rs index a8fc41151ae..0f7ce123721 100644 --- a/crates/vm/src/builtins/union.rs +++ b/crates/vm/src/builtins/union.rs @@ -9,7 +9,7 @@ use crate::{ convert::ToPyObject, function::PyComparisonValue, protocol::{PyMappingMethods, PyNumberMethods}, - stdlib::typing::{TypeAliasType, call_typing_func_object}, + stdlib::_typing::{TypeAliasType, call_typing_func_object}, types::{AsMapping, AsNumber, Comparable, GetAttr, Hashable, PyComparisonOp, Representable}, }; use alloc::fmt; diff --git a/crates/vm/src/frame.rs b/crates/vm/src/frame.rs index 7aea8927663..5dad43ea822 100644 --- a/crates/vm/src/frame.rs +++ b/crates/vm/src/frame.rs @@ -29,7 +29,7 @@ use crate::{ protocol::{PyIter, PyIterReturn}, scope::Scope, sliceable::SliceableSequenceOp, - stdlib::{builtins, sys::monitoring, typing}, + stdlib::{_typing, builtins, sys::monitoring}, types::{PyComparisonOp, PyTypeFlags}, vm::{Context, PyMethod}, }; @@ -9134,19 +9134,19 @@ impl ExecutingFrame<'_> { } bytecode::IntrinsicFunction1::TypeVar => { let type_var: PyObjectRef = - typing::TypeVar::new(vm, arg.clone(), vm.ctx.none(), vm.ctx.none()) + _typing::TypeVar::new(vm, arg.clone(), vm.ctx.none(), vm.ctx.none()) .into_ref(&vm.ctx) .into(); Ok(type_var) } bytecode::IntrinsicFunction1::ParamSpec => { - let param_spec: PyObjectRef = typing::ParamSpec::new(arg.clone(), vm) + let param_spec: PyObjectRef = _typing::ParamSpec::new(arg.clone(), vm) .into_ref(&vm.ctx) .into(); Ok(param_spec) } bytecode::IntrinsicFunction1::TypeVarTuple => { - let type_var_tuple: PyObjectRef = typing::TypeVarTuple::new(arg.clone(), vm) + let type_var_tuple: PyObjectRef = _typing::TypeVarTuple::new(arg.clone(), vm) .into_ref(&vm.ctx) .into(); Ok(type_var_tuple) @@ -9179,7 +9179,7 @@ impl ExecutingFrame<'_> { let name = name .downcast::() .map_err(|_| vm.new_type_error("TypeAliasType name must be a string"))?; - let type_alias = typing::TypeAliasType::new(name, type_params, compute_value); + let type_alias = _typing::TypeAliasType::new(name, type_params, compute_value); Ok(type_alias.into_ref(&vm.ctx).into()) } bytecode::IntrinsicFunction1::ListToTuple => { @@ -9225,7 +9225,7 @@ impl ExecutingFrame<'_> { ) -> PyResult { match func { bytecode::IntrinsicFunction2::SetTypeparamDefault => { - crate::stdlib::typing::set_typeparam_default(arg1, arg2, vm) + crate::stdlib::_typing::set_typeparam_default(arg1, arg2, vm) } bytecode::IntrinsicFunction2::SetFunctionTypeParams => { // arg1 is the function, arg2 is the type params tuple @@ -9235,14 +9235,14 @@ impl ExecutingFrame<'_> { } bytecode::IntrinsicFunction2::TypeVarWithBound => { let type_var: PyObjectRef = - typing::TypeVar::new(vm, arg1.clone(), arg2, vm.ctx.none()) + _typing::TypeVar::new(vm, arg1.clone(), arg2, vm.ctx.none()) .into_ref(&vm.ctx) .into(); Ok(type_var) } bytecode::IntrinsicFunction2::TypeVarWithConstraint => { let type_var: PyObjectRef = - typing::TypeVar::new(vm, arg1.clone(), vm.ctx.none(), arg2) + _typing::TypeVar::new(vm, arg1.clone(), vm.ctx.none(), arg2) .into_ref(&vm.ctx) .into(); Ok(type_var) diff --git a/crates/vm/src/ospath.rs b/crates/vm/src/ospath.rs index 00195460ea3..d3123a87acb 100644 --- a/crates/vm/src/ospath.rs +++ b/crates/vm/src/ospath.rs @@ -86,7 +86,7 @@ impl PathConverter { .class() .is(crate::builtins::bool_::PyBool::static_type()) { - crate::stdlib::warnings::warn( + crate::stdlib::_warnings::warn( vm.ctx.exceptions.runtime_warning, "bool is used as a file descriptor".to_owned(), 1, diff --git a/crates/vm/src/protocol/number.rs b/crates/vm/src/protocol/number.rs index 542afce2c6c..36dbd5b8843 100644 --- a/crates/vm/src/protocol/number.rs +++ b/crates/vm/src/protocol/number.rs @@ -11,7 +11,7 @@ use crate::{ common::int::{BytesToIntError, bytes_to_int}, function::ArgBytesLike, object::{Traverse, TraverseFn}, - stdlib::warnings, + stdlib::_warnings, }; pub type PyNumberUnaryFunc = fn(PyNumber<'_>, &VirtualMachine) -> PyResult; @@ -59,7 +59,7 @@ impl PyObject { } else if let Some(i) = self.number().int(vm).or_else(|| self.try_index_opt(vm)) { i } else if let Ok(Some(f)) = vm.get_special_method(self, identifier!(vm, __trunc__)) { - warnings::warn( + _warnings::warn( vm.ctx.exceptions.deprecation_warning, "The delegation of int() to __trunc__ is deprecated.".to_owned(), 1, @@ -589,7 +589,7 @@ impl PyNumber<'_> { let ret_class = ret.class().to_owned(); if let Some(ret) = ret.downcast_ref::() { - warnings::warn( + _warnings::warn( vm.ctx.exceptions.deprecation_warning, format!( "__int__ returned non-int (type {ret_class}). \ @@ -622,7 +622,7 @@ impl PyNumber<'_> { let ret_class = ret.class().to_owned(); if let Some(ret) = ret.downcast_ref::() { - warnings::warn( + _warnings::warn( vm.ctx.exceptions.deprecation_warning, format!( "__index__ returned non-int (type {ret_class}). \ @@ -655,7 +655,7 @@ impl PyNumber<'_> { let ret_class = ret.class().to_owned(); if let Some(ret) = ret.downcast_ref::() { - warnings::warn( + _warnings::warn( vm.ctx.exceptions.deprecation_warning, format!( "__float__ returned non-float (type {ret_class}). \ diff --git a/crates/vm/src/signal.rs b/crates/vm/src/signal.rs index 177ba06b84d..3caf8cb8e30 100644 --- a/crates/vm/src/signal.rs +++ b/crates/vm/src/signal.rs @@ -121,7 +121,7 @@ pub fn assert_in_range(signum: i32, vm: &VirtualMachine) -> PyResult<()> { #[allow(dead_code)] #[cfg(all(not(target_arch = "wasm32"), feature = "host_env"))] pub fn set_interrupt_ex(signum: i32, vm: &VirtualMachine) -> PyResult<()> { - use crate::stdlib::signal::_signal::{SIG_DFL, SIG_IGN, run_signal}; + use crate::stdlib::_signal::_signal::{SIG_DFL, SIG_IGN, run_signal}; assert_in_range(signum, vm)?; match signum as usize { diff --git a/crates/vm/src/stdlib/ast.rs b/crates/vm/src/stdlib/_ast.rs similarity index 99% rename from crates/vm/src/stdlib/ast.rs rename to crates/vm/src/stdlib/_ast.rs index 008c919479a..73819e257c1 100644 --- a/crates/vm/src/stdlib/ast.rs +++ b/crates/vm/src/stdlib/_ast.rs @@ -9,8 +9,8 @@ pub(crate) use python::_ast::module_def; mod pyast; use crate::builtins::{PyInt, PyStr}; -use crate::stdlib::ast::module::{Mod, ModFunctionType, ModInteractive}; -use crate::stdlib::ast::node::BoxedSlice; +use crate::stdlib::_ast::module::{Mod, ModFunctionType, ModInteractive}; +use crate::stdlib::_ast::node::BoxedSlice; use crate::{ AsObject, Context, Py, PyObject, PyObjectRef, PyPayload, PyRef, PyRefExact, PyResult, TryFromObject, VirtualMachine, diff --git a/crates/vm/src/stdlib/ast/argument.rs b/crates/vm/src/stdlib/_ast/argument.rs similarity index 100% rename from crates/vm/src/stdlib/ast/argument.rs rename to crates/vm/src/stdlib/_ast/argument.rs diff --git a/crates/vm/src/stdlib/ast/basic.rs b/crates/vm/src/stdlib/_ast/basic.rs similarity index 100% rename from crates/vm/src/stdlib/ast/basic.rs rename to crates/vm/src/stdlib/_ast/basic.rs diff --git a/crates/vm/src/stdlib/ast/constant.rs b/crates/vm/src/stdlib/_ast/constant.rs similarity index 100% rename from crates/vm/src/stdlib/ast/constant.rs rename to crates/vm/src/stdlib/_ast/constant.rs diff --git a/crates/vm/src/stdlib/ast/elif_else_clause.rs b/crates/vm/src/stdlib/_ast/elif_else_clause.rs similarity index 100% rename from crates/vm/src/stdlib/ast/elif_else_clause.rs rename to crates/vm/src/stdlib/_ast/elif_else_clause.rs diff --git a/crates/vm/src/stdlib/ast/exception.rs b/crates/vm/src/stdlib/_ast/exception.rs similarity index 100% rename from crates/vm/src/stdlib/ast/exception.rs rename to crates/vm/src/stdlib/_ast/exception.rs diff --git a/crates/vm/src/stdlib/ast/expression.rs b/crates/vm/src/stdlib/_ast/expression.rs similarity index 99% rename from crates/vm/src/stdlib/ast/expression.rs rename to crates/vm/src/stdlib/_ast/expression.rs index b18968e3c1c..cbc47dde9fb 100644 --- a/crates/vm/src/stdlib/ast/expression.rs +++ b/crates/vm/src/stdlib/_ast/expression.rs @@ -1,5 +1,5 @@ use super::*; -use crate::stdlib::ast::{ +use crate::stdlib::_ast::{ argument::{merge_function_call_arguments, split_function_call_arguments}, constant::Constant, string::JoinedStr, diff --git a/crates/vm/src/stdlib/ast/module.rs b/crates/vm/src/stdlib/_ast/module.rs similarity index 99% rename from crates/vm/src/stdlib/ast/module.rs rename to crates/vm/src/stdlib/_ast/module.rs index cfedba606b0..b4c2468d33b 100644 --- a/crates/vm/src/stdlib/ast/module.rs +++ b/crates/vm/src/stdlib/_ast/module.rs @@ -1,5 +1,5 @@ use super::*; -use crate::stdlib::ast::type_ignore::TypeIgnore; +use crate::stdlib::_ast::type_ignore::TypeIgnore; use rustpython_compiler_core::SourceFile; /// Represents the different types of Python module structures. diff --git a/crates/vm/src/stdlib/ast/node.rs b/crates/vm/src/stdlib/_ast/node.rs similarity index 100% rename from crates/vm/src/stdlib/ast/node.rs rename to crates/vm/src/stdlib/_ast/node.rs diff --git a/crates/vm/src/stdlib/ast/operator.rs b/crates/vm/src/stdlib/_ast/operator.rs similarity index 100% rename from crates/vm/src/stdlib/ast/operator.rs rename to crates/vm/src/stdlib/_ast/operator.rs diff --git a/crates/vm/src/stdlib/ast/other.rs b/crates/vm/src/stdlib/_ast/other.rs similarity index 100% rename from crates/vm/src/stdlib/ast/other.rs rename to crates/vm/src/stdlib/_ast/other.rs diff --git a/crates/vm/src/stdlib/ast/parameter.rs b/crates/vm/src/stdlib/_ast/parameter.rs similarity index 100% rename from crates/vm/src/stdlib/ast/parameter.rs rename to crates/vm/src/stdlib/_ast/parameter.rs diff --git a/crates/vm/src/stdlib/ast/pattern.rs b/crates/vm/src/stdlib/_ast/pattern.rs similarity index 100% rename from crates/vm/src/stdlib/ast/pattern.rs rename to crates/vm/src/stdlib/_ast/pattern.rs diff --git a/crates/vm/src/stdlib/ast/pyast.rs b/crates/vm/src/stdlib/_ast/pyast.rs similarity index 100% rename from crates/vm/src/stdlib/ast/pyast.rs rename to crates/vm/src/stdlib/_ast/pyast.rs diff --git a/crates/vm/src/stdlib/ast/python.rs b/crates/vm/src/stdlib/_ast/python.rs similarity index 99% rename from crates/vm/src/stdlib/ast/python.rs rename to crates/vm/src/stdlib/_ast/python.rs index 5744c50e4ea..5c97d759934 100644 --- a/crates/vm/src/stdlib/ast/python.rs +++ b/crates/vm/src/stdlib/_ast/python.rs @@ -12,7 +12,7 @@ pub(crate) mod _ast { class::{PyClassImpl, StaticType}, common::wtf8::Wtf8, function::{FuncArgs, KwArgs, PyMethodDef, PyMethodFlags}, - stdlib::ast::repr, + stdlib::_ast::repr, types::{Constructor, Initializer}, warn, }; diff --git a/crates/vm/src/stdlib/ast/repr.rs b/crates/vm/src/stdlib/_ast/repr.rs similarity index 99% rename from crates/vm/src/stdlib/ast/repr.rs rename to crates/vm/src/stdlib/_ast/repr.rs index 47fceb2386e..2897447fbec 100644 --- a/crates/vm/src/stdlib/ast/repr.rs +++ b/crates/vm/src/stdlib/_ast/repr.rs @@ -2,7 +2,7 @@ use crate::{ AsObject, PyObjectRef, PyResult, VirtualMachine, builtins::{PyList, PyTuple}, class::PyClassImpl, - stdlib::ast::NodeAst, + stdlib::_ast::NodeAst, }; use rustpython_common::wtf8::Wtf8Buf; diff --git a/crates/vm/src/stdlib/ast/statement.rs b/crates/vm/src/stdlib/_ast/statement.rs similarity index 99% rename from crates/vm/src/stdlib/ast/statement.rs rename to crates/vm/src/stdlib/_ast/statement.rs index 6eca073a4bb..cda34da40a3 100644 --- a/crates/vm/src/stdlib/ast/statement.rs +++ b/crates/vm/src/stdlib/_ast/statement.rs @@ -1,5 +1,5 @@ use super::*; -use crate::stdlib::ast::argument::{merge_class_def_args, split_class_def_args}; +use crate::stdlib::_ast::argument::{merge_class_def_args, split_class_def_args}; use rustpython_compiler_core::SourceFile; // sum diff --git a/crates/vm/src/stdlib/ast/string.rs b/crates/vm/src/stdlib/_ast/string.rs similarity index 100% rename from crates/vm/src/stdlib/ast/string.rs rename to crates/vm/src/stdlib/_ast/string.rs diff --git a/crates/vm/src/stdlib/ast/type_ignore.rs b/crates/vm/src/stdlib/_ast/type_ignore.rs similarity index 100% rename from crates/vm/src/stdlib/ast/type_ignore.rs rename to crates/vm/src/stdlib/_ast/type_ignore.rs diff --git a/crates/vm/src/stdlib/ast/type_parameters.rs b/crates/vm/src/stdlib/_ast/type_parameters.rs similarity index 100% rename from crates/vm/src/stdlib/ast/type_parameters.rs rename to crates/vm/src/stdlib/_ast/type_parameters.rs diff --git a/crates/vm/src/stdlib/ast/validate.rs b/crates/vm/src/stdlib/_ast/validate.rs similarity index 100% rename from crates/vm/src/stdlib/ast/validate.rs rename to crates/vm/src/stdlib/_ast/validate.rs diff --git a/crates/vm/src/stdlib/codecs.rs b/crates/vm/src/stdlib/_codecs.rs similarity index 100% rename from crates/vm/src/stdlib/codecs.rs rename to crates/vm/src/stdlib/_codecs.rs diff --git a/crates/vm/src/stdlib/collections.rs b/crates/vm/src/stdlib/_collections.rs similarity index 100% rename from crates/vm/src/stdlib/collections.rs rename to crates/vm/src/stdlib/_collections.rs diff --git a/crates/vm/src/stdlib/ctypes.rs b/crates/vm/src/stdlib/_ctypes.rs similarity index 100% rename from crates/vm/src/stdlib/ctypes.rs rename to crates/vm/src/stdlib/_ctypes.rs diff --git a/crates/vm/src/stdlib/ctypes/array.rs b/crates/vm/src/stdlib/_ctypes/array.rs similarity index 100% rename from crates/vm/src/stdlib/ctypes/array.rs rename to crates/vm/src/stdlib/_ctypes/array.rs diff --git a/crates/vm/src/stdlib/ctypes/base.rs b/crates/vm/src/stdlib/_ctypes/base.rs similarity index 100% rename from crates/vm/src/stdlib/ctypes/base.rs rename to crates/vm/src/stdlib/_ctypes/base.rs diff --git a/crates/vm/src/stdlib/ctypes/function.rs b/crates/vm/src/stdlib/_ctypes/function.rs similarity index 100% rename from crates/vm/src/stdlib/ctypes/function.rs rename to crates/vm/src/stdlib/_ctypes/function.rs diff --git a/crates/vm/src/stdlib/ctypes/library.rs b/crates/vm/src/stdlib/_ctypes/library.rs similarity index 100% rename from crates/vm/src/stdlib/ctypes/library.rs rename to crates/vm/src/stdlib/_ctypes/library.rs diff --git a/crates/vm/src/stdlib/ctypes/pointer.rs b/crates/vm/src/stdlib/_ctypes/pointer.rs similarity index 100% rename from crates/vm/src/stdlib/ctypes/pointer.rs rename to crates/vm/src/stdlib/_ctypes/pointer.rs diff --git a/crates/vm/src/stdlib/ctypes/simple.rs b/crates/vm/src/stdlib/_ctypes/simple.rs similarity index 100% rename from crates/vm/src/stdlib/ctypes/simple.rs rename to crates/vm/src/stdlib/_ctypes/simple.rs diff --git a/crates/vm/src/stdlib/ctypes/structure.rs b/crates/vm/src/stdlib/_ctypes/structure.rs similarity index 99% rename from crates/vm/src/stdlib/ctypes/structure.rs rename to crates/vm/src/stdlib/_ctypes/structure.rs index b009443e4ea..c9ab9205601 100644 --- a/crates/vm/src/stdlib/ctypes/structure.rs +++ b/crates/vm/src/stdlib/_ctypes/structure.rs @@ -3,7 +3,7 @@ use crate::builtins::{PyList, PyStr, PyTuple, PyType, PyTypeRef, PyUtf8Str}; use crate::convert::ToPyObject; use crate::function::{FuncArgs, OptionalArg, PySetterValue}; use crate::protocol::{BufferDescriptor, PyBuffer, PyNumberMethods}; -use crate::stdlib::warnings; +use crate::stdlib::_warnings; use crate::types::{AsBuffer, AsNumber, Constructor, Initializer, SetAttr}; use crate::{AsObject, Py, PyObjectRef, PyPayload, PyResult, VirtualMachine}; use alloc::borrow::Cow; @@ -259,7 +259,7 @@ impl PyCStructType { cls.name(), base_type_name, ); - warnings::warn(vm.ctx.exceptions.deprecation_warning, msg, 1, vm)?; + _warnings::warn(vm.ctx.exceptions.deprecation_warning, msg, 1, vm)?; } } diff --git a/crates/vm/src/stdlib/ctypes/union.rs b/crates/vm/src/stdlib/_ctypes/union.rs similarity index 99% rename from crates/vm/src/stdlib/ctypes/union.rs rename to crates/vm/src/stdlib/_ctypes/union.rs index bc595d35e4c..c1882141e98 100644 --- a/crates/vm/src/stdlib/ctypes/union.rs +++ b/crates/vm/src/stdlib/_ctypes/union.rs @@ -4,7 +4,7 @@ use crate::builtins::{PyList, PyStr, PyTuple, PyType, PyTypeRef, PyUtf8Str}; use crate::convert::ToPyObject; use crate::function::{ArgBytesLike, FuncArgs, OptionalArg, PySetterValue}; use crate::protocol::{BufferDescriptor, PyBuffer}; -use crate::stdlib::warnings; +use crate::stdlib::_warnings; use crate::types::{AsBuffer, Constructor, Initializer, SetAttr}; use crate::{AsObject, Py, PyObjectRef, PyPayload, PyResult, VirtualMachine}; use alloc::borrow::Cow; @@ -177,7 +177,7 @@ impl PyCUnionType { Python 3.19.", cls.name(), ); - warnings::warn(vm.ctx.exceptions.deprecation_warning, msg, 1, vm)?; + _warnings::warn(vm.ctx.exceptions.deprecation_warning, msg, 1, vm)?; } } diff --git a/crates/vm/src/stdlib/functools.rs b/crates/vm/src/stdlib/_functools.rs similarity index 100% rename from crates/vm/src/stdlib/functools.rs rename to crates/vm/src/stdlib/_functools.rs diff --git a/crates/vm/src/stdlib/imp.rs b/crates/vm/src/stdlib/_imp.rs similarity index 99% rename from crates/vm/src/stdlib/imp.rs rename to crates/vm/src/stdlib/_imp.rs index 66ce5239cd2..c0acb304a64 100644 --- a/crates/vm/src/stdlib/imp.rs +++ b/crates/vm/src/stdlib/_imp.rs @@ -10,7 +10,7 @@ pub use crate::vm::resolve_frozen_alias; #[cfg(feature = "threading")] #[pymodule(sub)] mod lock { - use crate::{PyResult, VirtualMachine, stdlib::thread::RawRMutex}; + use crate::{PyResult, VirtualMachine, stdlib::_thread::RawRMutex}; static IMP_LOCK: RawRMutex = RawRMutex::INIT; diff --git a/crates/vm/src/stdlib/io.rs b/crates/vm/src/stdlib/_io.rs similarity index 99% rename from crates/vm/src/stdlib/io.rs rename to crates/vm/src/stdlib/_io.rs index dadde9e8e32..c238dda3725 100644 --- a/crates/vm/src/stdlib/io.rs +++ b/crates/vm/src/stdlib/_io.rs @@ -5122,7 +5122,7 @@ mod _io { // Warn if line buffering is requested in binary mode if opts.buffering == 1 && matches!(mode.encode, EncodeMode::Bytes) { - crate::stdlib::warnings::warn( + crate::stdlib::_warnings::warn( vm.ctx.exceptions.runtime_warning, "line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used".to_owned(), 1, @@ -5248,7 +5248,7 @@ mod _io { } } let stacklevel = usize::try_from(stacklevel).unwrap_or(0); - crate::stdlib::warnings::warn( + crate::stdlib::_warnings::warn( vm.ctx.exceptions.encoding_warning, "'encoding' argument not specified".to_owned(), stacklevel, @@ -5488,7 +5488,7 @@ mod fileio { let name = args.name; // Check if bool is used as file descriptor if name.class().is(vm.ctx.types.bool_type) { - crate::stdlib::warnings::warn( + crate::stdlib::_warnings::warn( vm.ctx.exceptions.runtime_warning, "bool is used as a file descriptor".to_owned(), 1, @@ -5958,7 +5958,7 @@ mod fileio { .repr(vm) .map(|s| s.as_wtf8().to_owned()) .unwrap_or_else(|_| Wtf8Buf::from("")); - if let Err(e) = crate::stdlib::warnings::warn( + if let Err(e) = crate::stdlib::_warnings::warn( vm.ctx.exceptions.resource_warning, format!("unclosed file {repr}"), 1, @@ -6197,7 +6197,7 @@ mod winconsoleio { // Warn if bool is used as file descriptor if nameobj.class().is(vm.ctx.types.bool_type) { - crate::stdlib::warnings::warn( + crate::stdlib::_warnings::warn( vm.ctx.exceptions.runtime_warning, "bool is used as a file descriptor".to_owned(), 1, @@ -6511,7 +6511,7 @@ mod winconsoleio { .repr(vm) .map(|s| s.as_wtf8().to_owned()) .unwrap_or_else(|_| Wtf8Buf::from("")); - if let Err(e) = crate::stdlib::warnings::warn( + if let Err(e) = crate::stdlib::_warnings::warn( vm.ctx.exceptions.resource_warning, format!("unclosed file {repr}"), 1, diff --git a/crates/vm/src/stdlib/operator.rs b/crates/vm/src/stdlib/_operator.rs similarity index 100% rename from crates/vm/src/stdlib/operator.rs rename to crates/vm/src/stdlib/_operator.rs diff --git a/crates/vm/src/stdlib/signal.rs b/crates/vm/src/stdlib/_signal.rs similarity index 100% rename from crates/vm/src/stdlib/signal.rs rename to crates/vm/src/stdlib/_signal.rs diff --git a/crates/vm/src/stdlib/sre.rs b/crates/vm/src/stdlib/_sre.rs similarity index 100% rename from crates/vm/src/stdlib/sre.rs rename to crates/vm/src/stdlib/_sre.rs diff --git a/crates/vm/src/stdlib/stat.rs b/crates/vm/src/stdlib/_stat.rs similarity index 100% rename from crates/vm/src/stdlib/stat.rs rename to crates/vm/src/stdlib/_stat.rs diff --git a/crates/vm/src/stdlib/string.rs b/crates/vm/src/stdlib/_string.rs similarity index 100% rename from crates/vm/src/stdlib/string.rs rename to crates/vm/src/stdlib/_string.rs diff --git a/crates/vm/src/stdlib/symtable.rs b/crates/vm/src/stdlib/_symtable.rs similarity index 100% rename from crates/vm/src/stdlib/symtable.rs rename to crates/vm/src/stdlib/_symtable.rs diff --git a/crates/vm/src/stdlib/sysconfig.rs b/crates/vm/src/stdlib/_sysconfig.rs similarity index 100% rename from crates/vm/src/stdlib/sysconfig.rs rename to crates/vm/src/stdlib/_sysconfig.rs diff --git a/crates/vm/src/stdlib/sysconfigdata.rs b/crates/vm/src/stdlib/_sysconfigdata.rs similarity index 100% rename from crates/vm/src/stdlib/sysconfigdata.rs rename to crates/vm/src/stdlib/_sysconfigdata.rs diff --git a/crates/vm/src/stdlib/thread.rs b/crates/vm/src/stdlib/_thread.rs similarity index 100% rename from crates/vm/src/stdlib/thread.rs rename to crates/vm/src/stdlib/_thread.rs diff --git a/crates/vm/src/stdlib/typing.rs b/crates/vm/src/stdlib/_typing.rs similarity index 100% rename from crates/vm/src/stdlib/typing.rs rename to crates/vm/src/stdlib/_typing.rs diff --git a/crates/vm/src/stdlib/warnings.rs b/crates/vm/src/stdlib/_warnings.rs similarity index 100% rename from crates/vm/src/stdlib/warnings.rs rename to crates/vm/src/stdlib/_warnings.rs diff --git a/crates/vm/src/stdlib/weakref.rs b/crates/vm/src/stdlib/_weakref.rs similarity index 100% rename from crates/vm/src/stdlib/weakref.rs rename to crates/vm/src/stdlib/_weakref.rs diff --git a/crates/vm/src/stdlib/_winapi.rs b/crates/vm/src/stdlib/_winapi.rs index 9f3650b37a2..f7d9d0e703f 100644 --- a/crates/vm/src/stdlib/_winapi.rs +++ b/crates/vm/src/stdlib/_winapi.rs @@ -1537,7 +1537,7 @@ mod _winapi { #[cfg(feature = "threading")] let sigint_event = { - let is_main = crate::stdlib::thread::get_ident() == vm.state.main_thread_ident.load(); + let is_main = crate::stdlib::_thread::get_ident() == vm.state.main_thread_ident.load(); if is_main { let handle = crate::signal::get_sigint_event().unwrap_or_else(|| { let handle = unsafe { WinCreateEventW(null(), 1, 0, null()) }; diff --git a/crates/vm/src/stdlib/builtins.rs b/crates/vm/src/stdlib/builtins.rs index c145c5f8a41..9f306554661 100644 --- a/crates/vm/src/stdlib/builtins.rs +++ b/crates/vm/src/stdlib/builtins.rs @@ -260,7 +260,7 @@ mod builtins { } #[cfg(feature = "ast")] { - use crate::{class::PyClassImpl, stdlib::ast}; + use crate::{class::PyClassImpl, stdlib::_ast}; let feature_version = feature_version_from_arg(args._feature_version, vm)?; @@ -277,10 +277,10 @@ mod builtins { if args .source - .fast_isinstance(&ast::NodeAst::make_static_type()) + .fast_isinstance(&_ast::NodeAst::make_static_type()) { let flags: i32 = args.flags.map_or(Ok(0), |v| v.try_to_primitive(vm))?; - let is_ast_only = !(flags & ast::PY_CF_ONLY_AST).is_zero(); + let is_ast_only = !(flags & _ast::PY_CF_ONLY_AST).is_zero(); // func_type mode requires PyCF_ONLY_AST if mode_str == "func_type" && !is_ast_only { @@ -291,7 +291,7 @@ mod builtins { // compile(ast_node, ..., PyCF_ONLY_AST) returns the AST after validation if is_ast_only { - let (expected_type, expected_name) = ast::mode_type_and_name(mode_str) + let (expected_type, expected_name) = _ast::mode_type_and_name(mode_str) .ok_or_else(|| { vm.new_value_error( "compile() mode must be 'exec', 'eval', 'single' or 'func_type'", @@ -304,7 +304,7 @@ mod builtins { args.source.class().name() ))); } - ast::validate_ast_object(vm, args.source.clone())?; + _ast::validate_ast_object(vm, args.source.clone())?; return Ok(args.source); } @@ -317,7 +317,7 @@ mod builtins { let mode = mode_str .parse::() .map_err(|err| vm.new_value_error(err.to_string()))?; - return ast::compile( + return _ast::compile( vm, args.source, &args.filename.to_string_lossy(), @@ -346,16 +346,16 @@ mod builtins { let flags = args.flags.map_or(Ok(0), |v| v.try_to_primitive(vm))?; - if !(flags & !ast::PY_COMPILE_FLAGS_MASK).is_zero() { + if !(flags & !_ast::PY_COMPILE_FLAGS_MASK).is_zero() { return Err(vm.new_value_error("compile() unrecognized flags")); } - let allow_incomplete = !(flags & ast::PY_CF_ALLOW_INCOMPLETE_INPUT).is_zero(); - let type_comments = !(flags & ast::PY_CF_TYPE_COMMENTS).is_zero(); + let allow_incomplete = !(flags & _ast::PY_CF_ALLOW_INCOMPLETE_INPUT).is_zero(); + let type_comments = !(flags & _ast::PY_CF_TYPE_COMMENTS).is_zero(); let optimize_level = optimize; - if (flags & ast::PY_CF_ONLY_AST).is_zero() { + if (flags & _ast::PY_CF_ONLY_AST).is_zero() { #[cfg(not(feature = "compiler"))] { Err(vm.new_value_error(CODEGEN_NOT_SUPPORTED.to_owned())) @@ -366,7 +366,7 @@ mod builtins { let mode = mode_str .parse::() .map_err(|err| vm.new_value_error(err.to_string()))?; - let _ = ast::parse( + let _ = _ast::parse( vm, source, mode, @@ -398,14 +398,14 @@ mod builtins { } } else { if mode_str == "func_type" { - return ast::parse_func_type(vm, source, optimize_level, feature_version) + return _ast::parse_func_type(vm, source, optimize_level, feature_version) .map_err(|e| (e, Some(source), allow_incomplete).to_pyexception(vm)); } let mode = mode_str .parse::() .map_err(|err| vm.new_value_error(err.to_string()))?; - let parsed = ast::parse( + let parsed = _ast::parse( vm, source, mode, @@ -416,7 +416,7 @@ mod builtins { .map_err(|e| (e, Some(source), allow_incomplete).to_pyexception(vm))?; if mode_str == "single" { - return ast::wrap_interactive(vm, parsed); + return _ast::wrap_interactive(vm, parsed); } Ok(parsed) diff --git a/crates/vm/src/stdlib/mod.rs b/crates/vm/src/stdlib/mod.rs index f4f266bf161..42514c46dda 100644 --- a/crates/vm/src/stdlib/mod.rs +++ b/crates/vm/src/stdlib/mod.rs @@ -1,35 +1,31 @@ mod _abc; -mod _types; #[cfg(feature = "ast")] -pub(crate) mod ast; +pub(crate) mod _ast; +mod _codecs; +mod _collections; +mod _functools; +mod _imp; +pub mod _io; +mod _operator; +mod _sre; +mod _stat; +mod _string; +#[cfg(feature = "compiler")] +mod _symtable; +mod _sysconfig; +mod _sysconfigdata; +mod _types; +pub mod _typing; +pub mod _warnings; +mod _weakref; pub mod atexit; pub mod builtins; -mod codecs; -mod collections; pub mod errno; -mod functools; mod gc; -mod imp; -pub mod io; mod itertools; mod marshal; -mod operator; -// TODO: maybe make this an extension module, if we ever get those -// mod re; -mod sre; -mod stat; -mod string; -#[cfg(feature = "compiler")] -mod symtable; -mod sysconfig; -mod sysconfigdata; -#[cfg(feature = "threading")] -pub mod thread; pub mod time; mod typevar; -pub mod typing; -pub mod warnings; -mod weakref; #[cfg(feature = "host_env")] #[macro_use] @@ -47,7 +43,7 @@ pub mod posix; any(target_os = "linux", target_os = "macos", target_os = "windows"), not(any(target_env = "musl", target_env = "sgx")) ))] -mod ctypes; +mod _ctypes; #[cfg(all(feature = "host_env", windows))] pub(crate) mod msvcrt; @@ -58,10 +54,12 @@ pub(crate) mod msvcrt; ))] mod pwd; +#[cfg(feature = "host_env")] +pub(crate) mod _signal; +#[cfg(feature = "threading")] +pub mod _thread; #[cfg(all(feature = "host_env", windows))] mod _wmi; -#[cfg(feature = "host_env")] -pub(crate) mod signal; pub mod sys; #[cfg(all(feature = "host_env", windows))] #[path = "_winapi.rs"] @@ -83,28 +81,28 @@ pub fn builtin_module_defs(ctx: &Context) -> Vec<&'static PyModuleDef> { _abc::module_def(ctx), _types::module_def(ctx), #[cfg(feature = "ast")] - ast::module_def(ctx), + _ast::module_def(ctx), atexit::module_def(ctx), - codecs::module_def(ctx), - collections::module_def(ctx), + _codecs::module_def(ctx), + _collections::module_def(ctx), #[cfg(all( feature = "host_env", any(target_os = "linux", target_os = "macos", target_os = "windows"), not(any(target_env = "musl", target_env = "sgx")) ))] - ctypes::module_def(ctx), + _ctypes::module_def(ctx), errno::module_def(ctx), - functools::module_def(ctx), + _functools::module_def(ctx), gc::module_def(ctx), - imp::module_def(ctx), - io::module_def(ctx), + _imp::module_def(ctx), + _io::module_def(ctx), itertools::module_def(ctx), marshal::module_def(ctx), #[cfg(all(feature = "host_env", windows))] msvcrt::module_def(ctx), #[cfg(all(feature = "host_env", windows))] nt::module_def(ctx), - operator::module_def(ctx), + _operator::module_def(ctx), #[cfg(all(feature = "host_env", any(unix, target_os = "wasi")))] posix::module_def(ctx), #[cfg(all(feature = "host_env", not(any(unix, windows, target_os = "wasi"))))] @@ -116,20 +114,20 @@ pub fn builtin_module_defs(ctx: &Context) -> Vec<&'static PyModuleDef> { ))] pwd::module_def(ctx), #[cfg(feature = "host_env")] - signal::module_def(ctx), - sre::module_def(ctx), - stat::module_def(ctx), - string::module_def(ctx), + _signal::module_def(ctx), + _sre::module_def(ctx), + _stat::module_def(ctx), + _string::module_def(ctx), #[cfg(feature = "compiler")] - symtable::module_def(ctx), - sysconfigdata::module_def(ctx), - sysconfig::module_def(ctx), + _symtable::module_def(ctx), + _sysconfigdata::module_def(ctx), + _sysconfig::module_def(ctx), #[cfg(feature = "threading")] - thread::module_def(ctx), + _thread::module_def(ctx), time::module_def(ctx), - typing::module_def(ctx), - warnings::module_def(ctx), - weakref::module_def(ctx), + _typing::module_def(ctx), + _warnings::module_def(ctx), + _weakref::module_def(ctx), #[cfg(all(feature = "host_env", windows))] winapi::module_def(ctx), #[cfg(all(feature = "host_env", windows))] diff --git a/crates/vm/src/stdlib/os.rs b/crates/vm/src/stdlib/os.rs index d297f7e0fbc..03c5e33de76 100644 --- a/crates/vm/src/stdlib/os.rs +++ b/crates/vm/src/stdlib/os.rs @@ -111,7 +111,7 @@ pub(crate) fn warn_if_bool_fd(obj: &PyObjectRef, vm: &VirtualMachine) -> PyResul .class() .is(crate::builtins::bool_::PyBool::static_type()) { - crate::stdlib::warnings::warn( + crate::stdlib::_warnings::warn( vm.ctx.exceptions.runtime_warning, "bool is used as a file descriptor".to_owned(), 1, @@ -938,7 +938,7 @@ pub(super) mod _os { fn del(zelf: &Py, vm: &VirtualMachine) -> PyResult<()> { // Emit ResourceWarning if the iterator is not yet exhausted/closed if zelf.entries.read().is_some() { - let _ = crate::stdlib::warnings::warn( + let _ = crate::stdlib::_warnings::warn( vm.ctx.exceptions.resource_warning, format!("unclosed scandir iterator {:?}", zelf.as_object()), 1, @@ -1101,7 +1101,7 @@ pub(super) mod _os { impl Destructor for ScandirIteratorFd { fn del(zelf: &Py, vm: &VirtualMachine) -> PyResult<()> { if zelf.dir.lock().is_some() { - let _ = crate::stdlib::warnings::warn( + let _ = crate::stdlib::_warnings::warn( vm.ctx.exceptions.resource_warning, format!("unclosed scandir iterator {:?}", zelf.as_object()), 1, diff --git a/crates/vm/src/stdlib/posix.rs b/crates/vm/src/stdlib/posix.rs index 0deb22d6488..8cde18a47ba 100644 --- a/crates/vm/src/stdlib/posix.rs +++ b/crates/vm/src/stdlib/posix.rs @@ -769,7 +769,7 @@ pub mod module { run_at_forkers(before_forkers, true, vm); #[cfg(feature = "threading")] - crate::stdlib::imp::acquire_imp_lock_for_fork(); + crate::stdlib::_imp::acquire_imp_lock_for_fork(); #[cfg(feature = "threading")] vm.state.stop_the_world.stop_the_world(vm); @@ -790,12 +790,12 @@ pub mod module { // held by dead parent threads, causing deadlocks on any IO in the child. #[cfg(feature = "threading")] unsafe { - crate::stdlib::io::reinit_std_streams_after_fork(vm) + crate::stdlib::_io::reinit_std_streams_after_fork(vm) }; // Phase 2: Reset low-level atomic state (no locks needed). crate::signal::clear_after_fork(); - crate::stdlib::signal::_signal::clear_wakeup_fd_after_fork(); + crate::stdlib::_signal::_signal::clear_wakeup_fd_after_fork(); // Reset weakref stripe locks that may have been held during fork. #[cfg(feature = "threading")] @@ -804,13 +804,13 @@ pub mod module { // Phase 3: Clean up thread state. Locks are now reinit'd so we can // acquire them normally instead of using try_lock(). #[cfg(feature = "threading")] - crate::stdlib::thread::after_fork_child(vm); + crate::stdlib::_thread::after_fork_child(vm); // CPython parity: reinit import lock ownership metadata in child // and release the lock acquired by PyOS_BeforeFork(). #[cfg(feature = "threading")] unsafe { - crate::stdlib::imp::after_fork_child_imp_lock_release() + crate::stdlib::_imp::after_fork_child_imp_lock_release() }; // Initialize signal handlers for the child's main thread. @@ -857,7 +857,7 @@ pub mod module { crate::gc_state::gc_state().reinit_after_fork(); // Import lock (RawReentrantMutex) - crate::stdlib::imp::reinit_imp_lock_after_fork(); + crate::stdlib::_imp::reinit_imp_lock_after_fork(); } } @@ -866,7 +866,7 @@ pub mod module { vm.state.stop_the_world.start_the_world(vm); #[cfg(feature = "threading")] - crate::stdlib::imp::release_imp_lock_after_fork_parent(); + crate::stdlib::_imp::release_imp_lock_after_fork_parent(); let after_forkers_parent: Vec = vm.state.after_forkers_parent.lock().clone(); run_at_forkers(after_forkers_parent, false, vm); @@ -994,7 +994,7 @@ pub mod module { // Match PyErr_WarnFormat(..., stacklevel=1) in CPython. // Best effort: ignore failures like CPython does in this path. let _ = - crate::stdlib::warnings::warn(vm.ctx.exceptions.deprecation_warning, msg, 1, vm); + crate::stdlib::_warnings::warn(vm.ctx.exceptions.deprecation_warning, msg, 1, vm); } } diff --git a/crates/vm/src/stdlib/sys.rs b/crates/vm/src/stdlib/sys.rs index 40ff2eb25b8..33325c9dc60 100644 --- a/crates/vm/src/stdlib/sys.rs +++ b/crates/vm/src/stdlib/sys.rs @@ -45,7 +45,7 @@ mod sys { convert::ToPyObject, frame::{Frame, FrameRef}, function::{FuncArgs, KwArgs, OptionalArg, PosArgs}, - stdlib::{builtins, warnings::warn}, + stdlib::{_warnings::warn, builtins}, types::PyStructSequence, version, vm::{Settings, VirtualMachine}, @@ -1037,7 +1037,7 @@ mod sys { #[pyfunction] fn _current_frames(vm: &VirtualMachine) -> PyResult { use crate::AsObject; - use crate::stdlib::thread::get_all_current_frames; + use crate::stdlib::_thread::get_all_current_frames; let frames = get_all_current_frames(vm); let dict = vm.ctx.new_dict(); @@ -1633,7 +1633,7 @@ mod sys { #[cfg(feature = "threading")] impl ThreadInfoData { const INFO: Self = Self { - name: crate::stdlib::thread::_thread::PYTHREAD_NAME, + name: crate::stdlib::_thread::_thread::PYTHREAD_NAME, // As I know, there's only way to use lock as "Mutex" in Rust // with satisfying python document spec. lock: Some("mutex+cond"), diff --git a/crates/vm/src/stdlib/typevar.rs b/crates/vm/src/stdlib/typevar.rs index 0993d466e74..b28fad21bd7 100644 --- a/crates/vm/src/stdlib/typevar.rs +++ b/crates/vm/src/stdlib/typevar.rs @@ -10,7 +10,7 @@ pub(crate) mod typevar { common::lock::PyMutex, function::{FuncArgs, PyComparisonValue}, protocol::PyNumberMethods, - stdlib::typing::{call_typing_func_object, decl::const_evaluator_alloc}, + stdlib::_typing::{call_typing_func_object, decl::const_evaluator_alloc}, types::{AsNumber, Comparable, Constructor, Iterable, PyComparisonOp, Representable}, }; diff --git a/crates/vm/src/types/zoo.rs b/crates/vm/src/types/zoo.rs index a9999211680..0394f672cf8 100644 --- a/crates/vm/src/types/zoo.rs +++ b/crates/vm/src/types/zoo.rs @@ -198,7 +198,7 @@ impl TypeZoo { weakproxy_type: weakproxy::PyWeakProxy::init_builtin_type(), method_descriptor_type: descriptor::PyMethodDescriptor::init_builtin_type(), none_type: singletons::PyNone::init_builtin_type(), - typing_no_default_type: crate::stdlib::typing::NoDefault::init_builtin_type(), + typing_no_default_type: crate::stdlib::_typing::NoDefault::init_builtin_type(), not_implemented_type: singletons::PyNotImplemented::init_builtin_type(), generic_alias_type: genericalias::PyGenericAlias::init_builtin_type(), generic_alias_iterator_type: genericalias::PyGenericAliasIterator::init_builtin_type(), @@ -265,6 +265,6 @@ impl TypeZoo { interpolation::init(context); template::init(context); descriptor::init(context); - crate::stdlib::typing::init(context); + crate::stdlib::_typing::init(context); } } diff --git a/crates/vm/src/vm/context.rs b/crates/vm/src/vm/context.rs index dfd8829549f..767d100bff4 100644 --- a/crates/vm/src/vm/context.rs +++ b/crates/vm/src/vm/context.rs @@ -42,7 +42,7 @@ pub struct Context { pub ellipsis: PyRef, pub not_implemented: PyRef, - pub typing_no_default: PyRef, + pub typing_no_default: PyRef, pub types: TypeZoo, pub exceptions: exceptions::ExceptionZoo, @@ -313,8 +313,8 @@ impl Context { let not_implemented = create_object(PyNotImplemented, PyNotImplemented::static_type()); let typing_no_default = create_object( - crate::stdlib::typing::NoDefault, - crate::stdlib::typing::NoDefault::static_type(), + crate::stdlib::_typing::NoDefault, + crate::stdlib::_typing::NoDefault::static_type(), ); let int_cache_pool = Self::INT_CACHE_POOL_RANGE diff --git a/crates/vm/src/vm/mod.rs b/crates/vm/src/vm/mod.rs index 72899016675..e2af043d619 100644 --- a/crates/vm/src/vm/mod.rs +++ b/crates/vm/src/vm/mod.rs @@ -325,7 +325,7 @@ impl StopTheWorldState { /// to self-suspend in `check_signals`. pub fn stop_the_world(&self, vm: &VirtualMachine) { let start = std::time::Instant::now(); - let requester_ident = crate::stdlib::thread::get_ident(); + let requester_ident = crate::stdlib::_thread::get_ident(); self.requester.store(requester_ident, Ordering::Relaxed); self.stats_stop_calls.fetch_add(1, Ordering::Relaxed); let initial_countdown = self.init_thread_countdown(vm); @@ -562,7 +562,7 @@ pub(super) fn stw_trace(msg: core::fmt::Arguments<'_>) { let _ = writeln!( &mut out, "[rp-stw tid={}] {}", - crate::stdlib::thread::get_ident(), + crate::stdlib::_thread::get_ident(), msg ); unsafe { @@ -604,13 +604,13 @@ pub struct PyGlobalState { pub main_thread_ident: AtomicCell, /// Registry of all threads' slots for sys._current_frames() and sys._current_exceptions() #[cfg(feature = "threading")] - pub thread_frames: parking_lot::Mutex>, + pub thread_frames: parking_lot::Mutex>, /// Registry of all ThreadHandles for fork cleanup #[cfg(feature = "threading")] - pub thread_handles: parking_lot::Mutex>, + pub thread_handles: parking_lot::Mutex>, /// Registry for non-daemon threads that need to be joined at shutdown #[cfg(feature = "threading")] - pub shutdown_handles: parking_lot::Mutex>, + pub shutdown_handles: parking_lot::Mutex>, /// sys.monitoring state (tool names, events, callbacks) pub monitoring: PyMutex, /// Fast-path mask: OR of all tools' events. 0 means no monitoring overhead. @@ -685,7 +685,7 @@ impl VirtualMachine { pub(crate) fn is_main_thread(&self) -> bool { #[cfg(feature = "threading")] { - crate::stdlib::thread::get_ident() == self.state.main_thread_ident.load() + crate::stdlib::_thread::get_ident() == self.state.main_thread_ident.load() } #[cfg(not(feature = "threading"))] { @@ -874,7 +874,7 @@ impl VirtualMachine { // Initialize main thread ident before any threading operations #[cfg(feature = "threading")] - stdlib::thread::init_main_thread_ident(self); + stdlib::_thread::init_main_thread_ident(self); stdlib::builtins::init_module(self, &self.builtins); let callable_cache_init = self.init_callable_cache(); @@ -904,10 +904,10 @@ impl VirtualMachine { let make_stdio = |name: &str, fd: i32, write: bool| -> PyResult { let buffered_stdio = self.state.config.settings.buffered_stdio; let unbuffered = write && !buffered_stdio; - let buf = crate::stdlib::io::open( + let buf = crate::stdlib::_io::open( self.ctx.new_int(fd).into(), Some(if write { "wb" } else { "rb" }), - crate::stdlib::io::OpenArgs { + crate::stdlib::_io::OpenArgs { buffering: if unbuffered { 0 } else { -1 }, closefd: false, ..Default::default() diff --git a/crates/vm/src/vm/thread.rs b/crates/vm/src/vm/thread.rs index 13addacd516..e7cc64f00b4 100644 --- a/crates/vm/src/vm/thread.rs +++ b/crates/vm/src/vm/thread.rs @@ -110,7 +110,7 @@ pub fn enter_vm(vm: &VirtualMachine, f: impl FnOnce() -> R) -> R { fn init_thread_slot_if_needed(vm: &VirtualMachine) { CURRENT_THREAD_SLOT.with(|slot| { if slot.borrow().is_none() { - let thread_id = crate::stdlib::thread::get_ident(); + let thread_id = crate::stdlib::_thread::get_ident(); let mut registry = vm.state.thread_frames.lock(); let new_slot = Arc::new(ThreadSlot { frames: parking_lot::Mutex::new(Vec::new()), @@ -424,7 +424,7 @@ pub fn get_all_current_exceptions(vm: &VirtualMachine) -> Vec<(u64, Option = vm.frames.borrow().clone(); let new_slot = Arc::new(ThreadSlot { frames: parking_lot::Mutex::new(current_frames), diff --git a/crates/vm/src/vm/vm_ops.rs b/crates/vm/src/vm/vm_ops.rs index 1a362d67bed..d5c70f87386 100644 --- a/crates/vm/src/vm/vm_ops.rs +++ b/crates/vm/src/vm/vm_ops.rs @@ -1,5 +1,5 @@ use super::VirtualMachine; -use crate::stdlib::warnings; +use crate::stdlib::_warnings; use crate::{ PyRef, builtins::{PyInt, PyStr, PyStrRef, PyUtf8Str}, @@ -485,7 +485,7 @@ impl VirtualMachine { This returns the bitwise inversion of the underlying int object and is usually not what you expect from negating a bool. \ Use the 'not' operator for boolean negation or ~int(x) if you really want the bitwise inversion of the underlying int."; if a.fast_isinstance(self.ctx.types.bool_type) { - warnings::warn( + _warnings::warn( self.ctx.exceptions.deprecation_warning, STR.to_owned(), 1,