X Tutup
Skip to content

Commit a854ef2

Browse files
authored
Rename stdlib files to match Python module names (#7397)
1 parent 45d93f4 commit a854ef2

Some content is hidden

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

71 files changed

+140
-142
lines changed

crates/stdlib/src/array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ mod array {
3535
SaturatedSlice, SequenceIndex, SequenceIndexOp, SliceableSequenceMutOp,
3636
SliceableSequenceOp,
3737
},
38-
stdlib::warnings,
38+
stdlib::_warnings,
3939
types::{
4040
AsBuffer, AsMapping, AsSequence, Comparable, Constructor, IterNext, Iterable,
4141
PyComparisonOp, Representable, SelfIter,
@@ -647,7 +647,7 @@ mod array {
647647
}
648648

649649
if spec == 'u' {
650-
warnings::warn(
650+
_warnings::warn(
651651
vm.ctx.exceptions.deprecation_warning,
652652
"The 'u' type code is deprecated and will be removed in Python 3.16".to_owned(),
653653
1,

crates/stdlib/src/faulthandler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ mod decl {
405405
// Get all threads' frame stacks from the shared registry
406406
#[cfg(feature = "threading")]
407407
{
408-
let current_tid = rustpython_vm::stdlib::thread::get_ident();
408+
let current_tid = rustpython_vm::stdlib::_thread::get_ident();
409409
let registry = vm.state.thread_frames.lock();
410410

411411
// First dump non-current threads, then current thread last

crates/stdlib/src/fcntl.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ mod fcntl {
88
PyResult, VirtualMachine,
99
builtins::PyIntRef,
1010
function::{ArgMemoryBuffer, ArgStrOrBytesLike, Either, OptionalArg},
11-
stdlib::io,
11+
stdlib::_io,
1212
};
1313

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

5858
#[pyfunction]
5959
fn fcntl(
60-
io::Fildes(fd): io::Fildes,
60+
_io::Fildes(fd): _io::Fildes,
6161
cmd: i32,
6262
arg: OptionalArg<Either<ArgStrOrBytesLike, PyIntRef>>,
6363
vm: &VirtualMachine,
@@ -91,7 +91,7 @@ mod fcntl {
9191

9292
#[pyfunction]
9393
fn ioctl(
94-
io::Fildes(fd): io::Fildes,
94+
_io::Fildes(fd): _io::Fildes,
9595
request: i64,
9696
arg: OptionalArg<Either<Either<ArgMemoryBuffer, ArgStrOrBytesLike>, i32>>,
9797
mutate_flag: OptionalArg<bool>,
@@ -149,7 +149,7 @@ mod fcntl {
149149
// XXX: at the time of writing, wasi and redox don't have the necessary constants/function
150150
#[cfg(not(any(target_os = "wasi", target_os = "redox")))]
151151
#[pyfunction]
152-
fn flock(io::Fildes(fd): io::Fildes, operation: i32, vm: &VirtualMachine) -> PyResult {
152+
fn flock(_io::Fildes(fd): _io::Fildes, operation: i32, vm: &VirtualMachine) -> PyResult {
153153
let ret = unsafe { libc::flock(fd, operation) };
154154
// TODO: add support for platforms that don't have a builtin `flock` syscall
155155
if ret < 0 {
@@ -162,7 +162,7 @@ mod fcntl {
162162
#[cfg(not(any(target_os = "wasi", target_os = "redox")))]
163163
#[pyfunction]
164164
fn lockf(
165-
io::Fildes(fd): io::Fildes,
165+
_io::Fildes(fd): _io::Fildes,
166166
cmd: i32,
167167
len: OptionalArg<PyIntRef>,
168168
start: OptionalArg<PyIntRef>,

crates/stdlib/src/select.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ mod decl {
337337
common::lock::PyMutex,
338338
convert::{IntoPyException, ToPyObject},
339339
function::OptionalArg,
340-
stdlib::io::Fildes,
340+
stdlib::_io::Fildes,
341341
};
342342
use core::{convert::TryFrom, time::Duration};
343343
use libc::pollfd;
@@ -554,7 +554,7 @@ mod decl {
554554
common::lock::{PyRwLock, PyRwLockReadGuard},
555555
convert::{IntoPyException, ToPyObject},
556556
function::OptionalArg,
557-
stdlib::io::Fildes,
557+
stdlib::_io::Fildes,
558558
types::Constructor,
559559
};
560560
use core::ops::Deref;

crates/stdlib/src/ssl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ mod _ssl {
4848
function::{
4949
ArgBytesLike, ArgMemoryBuffer, Either, FuncArgs, OptionalArg, PyComparisonValue,
5050
},
51-
stdlib::warnings,
51+
stdlib::_warnings,
5252
types::{Comparable, Constructor, Hashable, PyComparisonOp, Representable},
5353
},
5454
};
@@ -976,7 +976,7 @@ mod _ssl {
976976

977977
// Warn if any deprecated options are being newly set
978978
if (set & opt_no) != 0 {
979-
warnings::warn(
979+
_warnings::warn(
980980
vm.ctx.exceptions.deprecation_warning,
981981
"ssl.OP_NO_SSL*/ssl.OP_NO_TLS* options are deprecated".to_owned(),
982982
2, // stack_level = 2

crates/vm/src/builtins/complex.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::{
77
convert::{IntoPyException, ToPyObject, ToPyResult},
88
function::{FuncArgs, OptionalArg, PyComparisonValue},
99
protocol::PyNumberMethods,
10-
stdlib::warnings,
10+
stdlib::_warnings,
1111
types::{AsNumber, Comparable, Constructor, Hashable, PyComparisonOp, Representable},
1212
};
1313
use core::cell::Cell;
@@ -95,7 +95,7 @@ impl PyObjectRef {
9595

9696
let ret_class = result.class().to_owned();
9797
if let Some(ret) = result.downcast_ref::<PyComplex>() {
98-
warnings::warn(
98+
_warnings::warn(
9999
vm.ctx.exceptions.deprecation_warning,
100100
format!(
101101
"__complex__ returned non-complex (type {ret_class}). \

crates/vm/src/builtins/genericalias.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ pub fn subscript_generic(type_params: PyObjectRef, vm: &VirtualMachine) -> PyRes
735735
PyTuple::new_ref(vec![type_params], &vm.ctx)
736736
};
737737

738-
let args = crate::stdlib::typing::unpack_typevartuples(&params, vm)?;
738+
let args = crate::stdlib::_typing::unpack_typevartuples(&params, vm)?;
739739

740740
generic_alias_class.call((generic_type, args.to_pyobject(vm)), vm)
741741
}

crates/vm/src/builtins/union.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{
99
convert::ToPyObject,
1010
function::PyComparisonValue,
1111
protocol::{PyMappingMethods, PyNumberMethods},
12-
stdlib::typing::{TypeAliasType, call_typing_func_object},
12+
stdlib::_typing::{TypeAliasType, call_typing_func_object},
1313
types::{AsMapping, AsNumber, Comparable, GetAttr, Hashable, PyComparisonOp, Representable},
1414
};
1515
use alloc::fmt;

crates/vm/src/frame.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use crate::{
2929
protocol::{PyIter, PyIterReturn},
3030
scope::Scope,
3131
sliceable::SliceableSequenceOp,
32-
stdlib::{builtins, sys::monitoring, typing},
32+
stdlib::{_typing, builtins, sys::monitoring},
3333
types::{PyComparisonOp, PyTypeFlags},
3434
vm::{Context, PyMethod},
3535
};
@@ -9134,19 +9134,19 @@ impl ExecutingFrame<'_> {
91349134
}
91359135
bytecode::IntrinsicFunction1::TypeVar => {
91369136
let type_var: PyObjectRef =
9137-
typing::TypeVar::new(vm, arg.clone(), vm.ctx.none(), vm.ctx.none())
9137+
_typing::TypeVar::new(vm, arg.clone(), vm.ctx.none(), vm.ctx.none())
91389138
.into_ref(&vm.ctx)
91399139
.into();
91409140
Ok(type_var)
91419141
}
91429142
bytecode::IntrinsicFunction1::ParamSpec => {
9143-
let param_spec: PyObjectRef = typing::ParamSpec::new(arg.clone(), vm)
9143+
let param_spec: PyObjectRef = _typing::ParamSpec::new(arg.clone(), vm)
91449144
.into_ref(&vm.ctx)
91459145
.into();
91469146
Ok(param_spec)
91479147
}
91489148
bytecode::IntrinsicFunction1::TypeVarTuple => {
9149-
let type_var_tuple: PyObjectRef = typing::TypeVarTuple::new(arg.clone(), vm)
9149+
let type_var_tuple: PyObjectRef = _typing::TypeVarTuple::new(arg.clone(), vm)
91509150
.into_ref(&vm.ctx)
91519151
.into();
91529152
Ok(type_var_tuple)
@@ -9179,7 +9179,7 @@ impl ExecutingFrame<'_> {
91799179
let name = name
91809180
.downcast::<crate::builtins::PyStr>()
91819181
.map_err(|_| vm.new_type_error("TypeAliasType name must be a string"))?;
9182-
let type_alias = typing::TypeAliasType::new(name, type_params, compute_value);
9182+
let type_alias = _typing::TypeAliasType::new(name, type_params, compute_value);
91839183
Ok(type_alias.into_ref(&vm.ctx).into())
91849184
}
91859185
bytecode::IntrinsicFunction1::ListToTuple => {
@@ -9225,7 +9225,7 @@ impl ExecutingFrame<'_> {
92259225
) -> PyResult {
92269226
match func {
92279227
bytecode::IntrinsicFunction2::SetTypeparamDefault => {
9228-
crate::stdlib::typing::set_typeparam_default(arg1, arg2, vm)
9228+
crate::stdlib::_typing::set_typeparam_default(arg1, arg2, vm)
92299229
}
92309230
bytecode::IntrinsicFunction2::SetFunctionTypeParams => {
92319231
// arg1 is the function, arg2 is the type params tuple
@@ -9235,14 +9235,14 @@ impl ExecutingFrame<'_> {
92359235
}
92369236
bytecode::IntrinsicFunction2::TypeVarWithBound => {
92379237
let type_var: PyObjectRef =
9238-
typing::TypeVar::new(vm, arg1.clone(), arg2, vm.ctx.none())
9238+
_typing::TypeVar::new(vm, arg1.clone(), arg2, vm.ctx.none())
92399239
.into_ref(&vm.ctx)
92409240
.into();
92419241
Ok(type_var)
92429242
}
92439243
bytecode::IntrinsicFunction2::TypeVarWithConstraint => {
92449244
let type_var: PyObjectRef =
9245-
typing::TypeVar::new(vm, arg1.clone(), vm.ctx.none(), arg2)
9245+
_typing::TypeVar::new(vm, arg1.clone(), vm.ctx.none(), arg2)
92469246
.into_ref(&vm.ctx)
92479247
.into();
92489248
Ok(type_var)

crates/vm/src/ospath.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl PathConverter {
8686
.class()
8787
.is(crate::builtins::bool_::PyBool::static_type())
8888
{
89-
crate::stdlib::warnings::warn(
89+
crate::stdlib::_warnings::warn(
9090
vm.ctx.exceptions.runtime_warning,
9191
"bool is used as a file descriptor".to_owned(),
9292
1,

0 commit comments

Comments
 (0)
X Tutup