PySettings is not a python object

This commit is contained in:
Jeong Yunwon
2022-04-23 07:08:08 +09:00
parent 946fc93170
commit ab7d921772
8 changed files with 22 additions and 23 deletions

View File

@@ -3,7 +3,7 @@ use criterion::{
Criterion, Throughput,
};
use rustpython_compiler::Mode;
use rustpython_vm::{common::ascii, InitParameter, Interpreter, PyResult, PySettings};
use rustpython_vm::{common::ascii, InitParameter, Interpreter, PyResult, Settings};
use std::{
ffi, fs, io,
path::{Path, PathBuf},
@@ -109,7 +109,7 @@ fn cpy_run_code(
}
fn bench_rustpy_code(group: &mut BenchmarkGroup<WallTime>, bench: &MicroBenchmark) {
let mut settings = PySettings::default();
let mut settings = Settings::default();
settings.path_list.push("Lib/".to_string());
settings.dont_write_bytecode = true;
settings.no_user_site = true;

View File

@@ -51,7 +51,7 @@ use rustpython_vm::{
compile, match_class,
scope::Scope,
stdlib::{atexit, sys},
AsObject, InitParameter, Interpreter, PyObjectRef, PyResult, PySettings, TryFromObject,
AsObject, InitParameter, Interpreter, PyObjectRef, PyResult, Settings, TryFromObject,
VirtualMachine,
};
use std::{env, path::Path, process, str::FromStr};
@@ -308,8 +308,8 @@ fn add_stdlib(vm: &mut VirtualMachine) {
/// Create settings by examining command line arguments and environment
/// variables.
fn create_settings(matches: &ArgMatches) -> PySettings {
let mut settings = PySettings::default();
fn create_settings(matches: &ArgMatches) -> Settings {
let mut settings = Settings::default();
settings.isolated = matches.is_present("isolate");
settings.ignore_environment = matches.is_present("ignore-environment");
settings.interactive = !matches.is_present("c")
@@ -320,7 +320,7 @@ fn create_settings(matches: &ArgMatches) -> PySettings {
let ignore_environment = settings.ignore_environment || settings.isolated;
// when rustpython-vm/pylib is enabled, PySettings::default().path_list has pylib::LIB_PATH
// when rustpython-vm/pylib is enabled, Settings::default().path_list has pylib::LIB_PATH
let maybe_pylib = settings.path_list.pop();
// add the current directory to sys.path
@@ -699,7 +699,7 @@ mod tests {
use super::*;
fn interpreter() -> Interpreter {
Interpreter::new_with_init(PySettings::default(), |vm| {
Interpreter::new_with_init(Settings::default(), |vm| {
add_stdlib(vm);
InitParameter::External
})

View File

@@ -90,7 +90,7 @@ pub use self::pyobject::{AsObject, PyMethod, PyPayload, PyRefExact, PyResult};
// pyobjectrc items
pub use self::pyobject::{Py, PyObject, PyObjectRef, PyRef, PyWeakRef};
pub use self::types::PyStructSequence;
pub use self::vm::{InitParameter, Interpreter, PyContext, PySettings, VirtualMachine};
pub use self::vm::{InitParameter, Interpreter, PyContext, Settings, VirtualMachine};
pub use rustpython_bytecode as bytecode;
pub use rustpython_common as common;

View File

@@ -15,7 +15,7 @@ mod sys {
stdlib::builtins,
types::PyStructSequence,
version,
vm::{PySettings, VirtualMachine},
vm::{Settings, VirtualMachine},
PyObjectRef, PyRef, PyRefExact, PyResult,
};
use num_traits::ToPrimitive;
@@ -550,7 +550,7 @@ mod sys {
#[pyimpl(with(PyStructSequence))]
impl Flags {
fn from_settings(settings: &PySettings) -> Self {
fn from_settings(settings: &Settings) -> Self {
Self {
debug: settings.debug as u8,
inspect: settings.inspect as u8,

View File

@@ -1,4 +1,4 @@
use super::{setting::PySettings, thread, InitParameter, VirtualMachine};
use super::{setting::Settings, thread, InitParameter, VirtualMachine};
/// The general interface for the VM
///
@@ -21,11 +21,11 @@ pub struct Interpreter {
}
impl Interpreter {
pub fn new(settings: PySettings, init: InitParameter) -> Self {
pub fn new(settings: Settings, init: InitParameter) -> Self {
Self::new_with_init(settings, |_| init)
}
pub fn new_with_init<F>(settings: PySettings, init: F) -> Self
pub fn new_with_init<F>(settings: Settings, init: F) -> Self
where
F: FnOnce(&mut VirtualMachine) -> InitParameter,
{
@@ -56,7 +56,7 @@ impl Interpreter {
impl Default for Interpreter {
fn default() -> Self {
Self::new(PySettings::default(), InitParameter::External)
Self::new(Settings::default(), InitParameter::External)
}
}

View File

@@ -42,7 +42,7 @@ use std::{
pub use context::PyContext;
pub use interpreter::Interpreter;
pub use setting::PySettings;
pub use setting::Settings;
// Objects are live when they are on stack, or referenced by a name (for now)
@@ -77,7 +77,7 @@ struct ExceptionStack {
}
pub struct PyGlobalState {
pub settings: PySettings,
pub settings: Settings,
pub module_inits: stdlib::StdlibMap,
pub frozen: HashMap<String, code::FrozenModule, ahash::RandomState>,
pub stacksize: AtomicCell<usize>,
@@ -95,7 +95,7 @@ pub enum InitParameter {
impl VirtualMachine {
/// Create a new `VirtualMachine` structure.
fn new(settings: PySettings) -> VirtualMachine {
fn new(settings: Settings) -> VirtualMachine {
flame_guard!("new VirtualMachine");
let ctx = PyContext::default();

View File

@@ -1,6 +1,6 @@
/// Struct containing all kind of settings for the python vm.
#[non_exhaustive]
pub struct PySettings {
pub struct Settings {
/// -d command line switch
pub debug: bool,
@@ -61,9 +61,9 @@ pub struct PySettings {
}
/// Sensible default settings.
impl Default for PySettings {
impl Default for Settings {
fn default() -> Self {
PySettings {
Settings {
debug: false,
inspect: false,
interactive: false,

View File

@@ -8,8 +8,7 @@ use rustpython_vm::{
builtins::PyWeak,
compile::{self, Mode},
scope::Scope,
InitParameter, Interpreter, PyObjectRef, PyPayload, PyRef, PyResult, PySettings,
VirtualMachine,
InitParameter, Interpreter, PyObjectRef, PyPayload, PyRef, PyResult, Settings, VirtualMachine,
};
use std::{
cell::RefCell,
@@ -42,7 +41,7 @@ fn init_window_module(vm: &VirtualMachine) -> PyObjectRef {
impl StoredVirtualMachine {
fn new(id: String, inject_browser_module: bool) -> StoredVirtualMachine {
let mut scope = None;
let interp = Interpreter::new_with_init(PySettings::default(), |vm| {
let interp = Interpreter::new_with_init(Settings::default(), |vm| {
vm.wasm_id = Some(id);
js_module::setup_js_module(vm);