mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
move builtins module to vm::stdlib::builtlins for consistency
This commit is contained in:
@@ -84,7 +84,4 @@ pub use zip::PyZip;
|
||||
pub use float::try_to_bigint as try_f64_to_bigint;
|
||||
pub use int::try_to_float as try_bigint_to_f64;
|
||||
|
||||
mod make_module;
|
||||
pub use make_module::{ascii, make_module, print};
|
||||
|
||||
pub use crate::exceptions::types::*;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
use crate::{
|
||||
builtins::{self, PyBaseExceptionRef, PyStrRef},
|
||||
builtins::{PyBaseExceptionRef, PyStrRef},
|
||||
common::float_ops,
|
||||
exceptions::IntoPyException,
|
||||
function::FuncArgs,
|
||||
stdlib::builtins,
|
||||
ItemProtocol, PyObjectRef, PyResult, TypeProtocol, VirtualMachine,
|
||||
};
|
||||
use itertools::{Itertools, PeekingNext};
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
use crate::common::{boxvec::BoxVec, lock::PyMutex};
|
||||
use crate::{
|
||||
builtins::PyBaseExceptionRef,
|
||||
builtins::{
|
||||
self,
|
||||
asyncgenerator::PyAsyncGenWrappedValue,
|
||||
coroutine::PyCoroutine,
|
||||
function::{PyCell, PyCellRef, PyFunction},
|
||||
@@ -10,7 +8,7 @@ use crate::{
|
||||
list, pystr, set,
|
||||
traceback::PyTraceback,
|
||||
tuple::{PyTuple, PyTupleTyped},
|
||||
PyCode, PyDict, PyDictRef, PySlice, PyStr, PyStrRef, PyTypeRef,
|
||||
PyBaseExceptionRef, PyCode, PyDict, PyDictRef, PySlice, PyStr, PyStrRef, PyTypeRef,
|
||||
},
|
||||
bytecode,
|
||||
coroutine::Coro,
|
||||
@@ -20,6 +18,7 @@ use crate::{
|
||||
protocol::PyIter,
|
||||
scope::Scope,
|
||||
slots::PyComparisonOp,
|
||||
stdlib::builtins,
|
||||
IdProtocol, ItemProtocol, PyMethod, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject,
|
||||
TypeProtocol, VirtualMachine,
|
||||
};
|
||||
|
||||
@@ -6,8 +6,8 @@ use crate::{PyObjectRef, VirtualMachine};
|
||||
/// Built-in functions, exceptions, and other objects.
|
||||
///
|
||||
/// Noteworthy: None is the `nil' object; Ellipsis represents `...' in slices.
|
||||
#[pymodule(name = "builtins")]
|
||||
mod decl {
|
||||
#[pymodule]
|
||||
mod builtins {
|
||||
use crate::builtins::{
|
||||
enumerate::PyReverseSequenceIterator,
|
||||
function::{PyCellRef, PyFunctionRef},
|
||||
@@ -891,12 +891,12 @@ mod decl {
|
||||
}
|
||||
}
|
||||
|
||||
pub use decl::{ascii, print};
|
||||
pub use builtins::{ascii, print};
|
||||
|
||||
pub fn make_module(vm: &VirtualMachine, module: PyObjectRef) {
|
||||
let ctx = &vm.ctx;
|
||||
|
||||
decl::extend_module(vm, &module);
|
||||
builtins::extend_module(vm, &module);
|
||||
|
||||
let debug_mode: bool = vm.state.settings.optimize == 0;
|
||||
extend_module!(vm, module, {
|
||||
@@ -4,6 +4,7 @@ pub(crate) mod ast;
|
||||
mod atexit;
|
||||
mod binascii;
|
||||
mod bisect;
|
||||
pub mod builtins;
|
||||
mod cmath;
|
||||
mod codecs;
|
||||
mod collections;
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
use num_traits::ToPrimitive;
|
||||
use std::{env, mem, path};
|
||||
|
||||
use crate::builtins::{PyStr, PyStrRef, PyTypeRef};
|
||||
use crate::common::{
|
||||
ascii,
|
||||
hash::{PyHash, PyUHash},
|
||||
};
|
||||
use crate::frame::FrameRef;
|
||||
use crate::function::{FuncArgs, OptionalArg, PosArgs};
|
||||
use crate::vm::{PySettings, VirtualMachine};
|
||||
use crate::{builtins, exceptions, py_io, version};
|
||||
use crate::{
|
||||
builtins::{PyStr, PyStrRef, PyTypeRef},
|
||||
exceptions,
|
||||
frame::FrameRef,
|
||||
function::{FuncArgs, OptionalArg, PosArgs},
|
||||
py_io,
|
||||
stdlib::builtins,
|
||||
version,
|
||||
vm::{PySettings, VirtualMachine},
|
||||
ItemProtocol, PyClassImpl, PyContext, PyObjectRef, PyRefExact, PyResult, PyStructSequence,
|
||||
};
|
||||
use num_traits::ToPrimitive;
|
||||
use std::{env, mem, path};
|
||||
|
||||
/*
|
||||
* The magic sys module.
|
||||
|
||||
@@ -8,13 +8,12 @@
|
||||
use crate::compile::{self, CompileError, CompileErrorType, CompileOpts};
|
||||
use crate::{
|
||||
builtins::{
|
||||
self,
|
||||
code::{self, PyCode},
|
||||
module, object,
|
||||
tuple::{PyTuple, PyTupleRef, PyTupleTyped},
|
||||
PyDictRef, PyInt, PyIntRef, PyList, PyModule, PyStr, PyStrRef, PyTypeRef,
|
||||
PyBaseException, PyBaseExceptionRef, PyDictRef, PyInt, PyIntRef, PyList, PyModule, PyStr,
|
||||
PyStrRef, PyTypeRef,
|
||||
},
|
||||
builtins::{PyBaseException, PyBaseExceptionRef},
|
||||
bytecode,
|
||||
codecs::CodecsRegistry,
|
||||
common::{ascii, hash::HashSecret, lock::PyMutex, rc::PyRc},
|
||||
@@ -325,7 +324,7 @@ impl VirtualMachine {
|
||||
panic!("Double Initialize Error");
|
||||
}
|
||||
|
||||
builtins::make_module(self, self.builtins.clone());
|
||||
stdlib::builtins::make_module(self, self.builtins.clone());
|
||||
stdlib::sys::make_module(self, self.sys_module.clone(), self.builtins.clone());
|
||||
|
||||
let mut inner_init = || -> PyResult<()> {
|
||||
|
||||
Reference in New Issue
Block a user