X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/stdlib/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion crates/stdlib/src/faulthandler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions crates/stdlib/src/fcntl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mod fcntl {
PyResult, VirtualMachine,
builtins::PyIntRef,
function::{ArgMemoryBuffer, ArgStrOrBytesLike, Either, OptionalArg},
stdlib::io,
stdlib::_io,
};

// TODO: supply these from <asm-generic/fnctl.h> (please file an issue/PR upstream):
Expand Down Expand Up @@ -57,7 +57,7 @@ mod fcntl {

#[pyfunction]
fn fcntl(
io::Fildes(fd): io::Fildes,
_io::Fildes(fd): _io::Fildes,
cmd: i32,
arg: OptionalArg<Either<ArgStrOrBytesLike, PyIntRef>>,
vm: &VirtualMachine,
Expand Down Expand Up @@ -91,7 +91,7 @@ mod fcntl {

#[pyfunction]
fn ioctl(
io::Fildes(fd): io::Fildes,
_io::Fildes(fd): _io::Fildes,
request: i64,
arg: OptionalArg<Either<Either<ArgMemoryBuffer, ArgStrOrBytesLike>, i32>>,
mutate_flag: OptionalArg<bool>,
Expand Down Expand Up @@ -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 {
Expand All @@ -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<PyIntRef>,
start: OptionalArg<PyIntRef>,
Expand Down
4 changes: 2 additions & 2 deletions crates/stdlib/src/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions crates/stdlib/src/ssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ mod _ssl {
function::{
ArgBytesLike, ArgMemoryBuffer, Either, FuncArgs, OptionalArg, PyComparisonValue,
},
stdlib::warnings,
stdlib::_warnings,
types::{Comparable, Constructor, Hashable, PyComparisonOp, Representable},
},
};
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions crates/vm/src/builtins/complex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -95,7 +95,7 @@ impl PyObjectRef {

let ret_class = result.class().to_owned();
if let Some(ret) = result.downcast_ref::<PyComplex>() {
warnings::warn(
_warnings::warn(
vm.ctx.exceptions.deprecation_warning,
format!(
"__complex__ returned non-complex (type {ret_class}). \
Expand Down
2 changes: 1 addition & 1 deletion crates/vm/src/builtins/genericalias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(&params, vm)?;
let args = crate::stdlib::_typing::unpack_typevartuples(&params, vm)?;

generic_alias_class.call((generic_type, args.to_pyobject(vm)), vm)
}
Expand Down
4 changes: 3 additions & 1 deletion crates/vm/src/builtins/tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PyTuple>) }.elements.len();
let len = unsafe { &*(obj as *const crate::Py<PyTuple>) }
.elements
.len();
if len == 0 || len > TupleFreeList::MAX_SAVE_SIZE {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/vm/src/builtins/union.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions crates/vm/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -9179,7 +9179,7 @@ impl ExecutingFrame<'_> {
let name = name
.downcast::<crate::builtins::PyStr>()
.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 => {
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion crates/vm/src/ospath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions crates/vm/src/protocol/number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
common::int::{BytesToIntError, bytes_to_int},
function::ArgBytesLike,
object::{Traverse, TraverseFn},
stdlib::warnings,
stdlib::_warnings,
};

pub type PyNumberUnaryFunc<R = PyObjectRef> = fn(PyNumber<'_>, &VirtualMachine) -> PyResult<R>;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -589,7 +589,7 @@ impl PyNumber<'_> {

let ret_class = ret.class().to_owned();
if let Some(ret) = ret.downcast_ref::<PyInt>() {
warnings::warn(
_warnings::warn(
vm.ctx.exceptions.deprecation_warning,
format!(
"__int__ returned non-int (type {ret_class}). \
Expand Down Expand Up @@ -622,7 +622,7 @@ impl PyNumber<'_> {

let ret_class = ret.class().to_owned();
if let Some(ret) = ret.downcast_ref::<PyInt>() {
warnings::warn(
_warnings::warn(
vm.ctx.exceptions.deprecation_warning,
format!(
"__index__ returned non-int (type {ret_class}). \
Expand Down Expand Up @@ -655,7 +655,7 @@ impl PyNumber<'_> {

let ret_class = ret.class().to_owned();
if let Some(ret) = ret.downcast_ref::<PyFloat>() {
warnings::warn(
_warnings::warn(
vm.ctx.exceptions.deprecation_warning,
format!(
"__float__ returned non-float (type {ret_class}). \
Expand Down
2 changes: 1 addition & 1 deletion crates/vm/src/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions crates/vm/src/stdlib/ast.rs → crates/vm/src/stdlib/_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)?;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)?;
}
}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading
Loading
X Tutup