mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Rename stdlib files to match Python module names (#7397)
This commit is contained in:
1 parent
0324b13cd3
commit
630cd8d715
71 files changed
+140
-142
No files matched your search
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
@@ -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,
|
||||
@@ -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>,
|
||||
@@ -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<PyIntRef>,
|
||||
start: OptionalArg<PyIntRef>,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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::<PyComplex>() {
|
||||
warnings::warn(
|
||||
_warnings::warn(
|
||||
vm.ctx.exceptions.deprecation_warning,
|
||||
format!(
|
||||
"__complex__ returned non-complex (type {ret_class}). \
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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::<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 => {
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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>;
|
||||
@@ -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::<PyInt>() {
|
||||
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::<PyInt>() {
|
||||
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::<PyFloat>() {
|
||||
warnings::warn(
|
||||
_warnings::warn(
|
||||
vm.ctx.exceptions.deprecation_warning,
|
||||
format!(
|
||||
"__float__ returned non-float (type {ret_class}). \
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -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,
|
||||
@@ -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.
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -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,
|
||||
};
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+2
-2
@@ -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)?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)?;
|
||||
}
|
||||
}
|
||||
|
||||
File renamed without changes.
@@ -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;
|
||||
|
||||
@@ -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("<file>"));
|
||||
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("<file>"));
|
||||
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,
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -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()) };
|
||||
|
||||
@@ -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::<crate::compiler::Mode>()
|
||||
.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::<parser::Mode>()
|
||||
.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::<parser::Mode>()
|
||||
.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)
|
||||
|
||||
+42
-44
@@ -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))]
|
||||
|
||||
@@ -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<Self>, 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<Self>, 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,
|
||||
|
||||
@@ -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<RawMutex, RawThreadId>)
|
||||
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<PyObjectRef> = 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<PyDictRef> {
|
||||
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"),
|
||||
|
||||
@@ -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},
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ pub struct Context {
|
||||
pub ellipsis: PyRef<PyEllipsis>,
|
||||
pub not_implemented: PyRef<PyNotImplemented>,
|
||||
|
||||
pub typing_no_default: PyRef<crate::stdlib::typing::NoDefault>,
|
||||
pub typing_no_default: PyRef<crate::stdlib::_typing::NoDefault>,
|
||||
|
||||
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
|
||||
|
||||
@@ -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<u64>,
|
||||
/// Registry of all threads' slots for sys._current_frames() and sys._current_exceptions()
|
||||
#[cfg(feature = "threading")]
|
||||
pub thread_frames: parking_lot::Mutex<HashMap<u64, stdlib::thread::CurrentFrameSlot>>,
|
||||
pub thread_frames: parking_lot::Mutex<HashMap<u64, stdlib::_thread::CurrentFrameSlot>>,
|
||||
/// Registry of all ThreadHandles for fork cleanup
|
||||
#[cfg(feature = "threading")]
|
||||
pub thread_handles: parking_lot::Mutex<Vec<stdlib::thread::HandleEntry>>,
|
||||
pub thread_handles: parking_lot::Mutex<Vec<stdlib::_thread::HandleEntry>>,
|
||||
/// Registry for non-daemon threads that need to be joined at shutdown
|
||||
#[cfg(feature = "threading")]
|
||||
pub shutdown_handles: parking_lot::Mutex<Vec<stdlib::thread::ShutdownEntry>>,
|
||||
pub shutdown_handles: parking_lot::Mutex<Vec<stdlib::_thread::ShutdownEntry>>,
|
||||
/// sys.monitoring state (tool names, events, callbacks)
|
||||
pub monitoring: PyMutex<stdlib::sys::monitoring::MonitoringState>,
|
||||
/// 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<PyObjectRef> {
|
||||
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()
|
||||
|
||||
@@ -110,7 +110,7 @@ pub fn enter_vm<R>(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<PyBas
|
||||
/// Cleanup thread slot for the current thread. Called at thread exit.
|
||||
#[cfg(feature = "threading")]
|
||||
pub fn cleanup_current_thread_frames(vm: &VirtualMachine) {
|
||||
let thread_id = crate::stdlib::thread::get_ident();
|
||||
let thread_id = crate::stdlib::_thread::get_ident();
|
||||
let current_slot = CURRENT_THREAD_SLOT.with(|slot| slot.borrow().as_ref().cloned());
|
||||
|
||||
// A dying thread should not remain logically ATTACHED while its
|
||||
@@ -473,7 +473,7 @@ pub fn cleanup_current_thread_frames(vm: &VirtualMachine) {
|
||||
/// VmState locks to unlocked.
|
||||
#[cfg(feature = "threading")]
|
||||
pub fn reinit_frame_slot_after_fork(vm: &VirtualMachine) {
|
||||
let current_ident = crate::stdlib::thread::get_ident();
|
||||
let current_ident = crate::stdlib::_thread::get_ident();
|
||||
let current_frames: Vec<FramePtr> = vm.frames.borrow().clone();
|
||||
let new_slot = Arc::new(ThreadSlot {
|
||||
frames: parking_lot::Mutex::new(current_frames),
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user