Skip to content

Commit ab7d921

Browse files
committed
PySettings is not a python object
1 parent 946fc93 commit ab7d921

File tree

8 files changed

+22
-23
lines changed

8 files changed

+22
-23
lines changed

benches/microbenchmarks.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use criterion::{
33
Criterion, Throughput,
44
};
55
use rustpython_compiler::Mode;
6-
use rustpython_vm::{common::ascii, InitParameter, Interpreter, PyResult, PySettings};
6+
use rustpython_vm::{common::ascii, InitParameter, Interpreter, PyResult, Settings};
77
use std::{
88
ffi, fs, io,
99
path::{Path, PathBuf},
@@ -109,7 +109,7 @@ fn cpy_run_code(
109109
}
110110

111111
fn bench_rustpy_code(group: &mut BenchmarkGroup<WallTime>, bench: &MicroBenchmark) {
112-
let mut settings = PySettings::default();
112+
let mut settings = Settings::default();
113113
settings.path_list.push("Lib/".to_string());
114114
settings.dont_write_bytecode = true;
115115
settings.no_user_site = true;

src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use rustpython_vm::{
5151
compile, match_class,
5252
scope::Scope,
5353
stdlib::{atexit, sys},
54-
AsObject, InitParameter, Interpreter, PyObjectRef, PyResult, PySettings, TryFromObject,
54+
AsObject, InitParameter, Interpreter, PyObjectRef, PyResult, Settings, TryFromObject,
5555
VirtualMachine,
5656
};
5757
use std::{env, path::Path, process, str::FromStr};
@@ -308,8 +308,8 @@ fn add_stdlib(vm: &mut VirtualMachine) {
308308

309309
/// Create settings by examining command line arguments and environment
310310
/// variables.
311-
fn create_settings(matches: &ArgMatches) -> PySettings {
312-
let mut settings = PySettings::default();
311+
fn create_settings(matches: &ArgMatches) -> Settings {
312+
let mut settings = Settings::default();
313313
settings.isolated = matches.is_present("isolate");
314314
settings.ignore_environment = matches.is_present("ignore-environment");
315315
settings.interactive = !matches.is_present("c")
@@ -320,7 +320,7 @@ fn create_settings(matches: &ArgMatches) -> PySettings {
320320

321321
let ignore_environment = settings.ignore_environment || settings.isolated;
322322

323-
// when rustpython-vm/pylib is enabled, PySettings::default().path_list has pylib::LIB_PATH
323+
// when rustpython-vm/pylib is enabled, Settings::default().path_list has pylib::LIB_PATH
324324
let maybe_pylib = settings.path_list.pop();
325325

326326
// add the current directory to sys.path
@@ -699,7 +699,7 @@ mod tests {
699699
use super::*;
700700

701701
fn interpreter() -> Interpreter {
702-
Interpreter::new_with_init(PySettings::default(), |vm| {
702+
Interpreter::new_with_init(Settings::default(), |vm| {
703703
add_stdlib(vm);
704704
InitParameter::External
705705
})

vm/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub use self::pyobject::{AsObject, PyMethod, PyPayload, PyRefExact, PyResult};
9090
// pyobjectrc items
9191
pub use self::pyobject::{Py, PyObject, PyObjectRef, PyRef, PyWeakRef};
9292
pub use self::types::PyStructSequence;
93-
pub use self::vm::{InitParameter, Interpreter, PyContext, PySettings, VirtualMachine};
93+
pub use self::vm::{InitParameter, Interpreter, PyContext, Settings, VirtualMachine};
9494

9595
pub use rustpython_bytecode as bytecode;
9696
pub use rustpython_common as common;

vm/src/stdlib/sys.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mod sys {
1515
stdlib::builtins,
1616
types::PyStructSequence,
1717
version,
18-
vm::{PySettings, VirtualMachine},
18+
vm::{Settings, VirtualMachine},
1919
PyObjectRef, PyRef, PyRefExact, PyResult,
2020
};
2121
use num_traits::ToPrimitive;
@@ -550,7 +550,7 @@ mod sys {
550550

551551
#[pyimpl(with(PyStructSequence))]
552552
impl Flags {
553-
fn from_settings(settings: &PySettings) -> Self {
553+
fn from_settings(settings: &Settings) -> Self {
554554
Self {
555555
debug: settings.debug as u8,
556556
inspect: settings.inspect as u8,

vm/src/vm/interpreter.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{setting::PySettings, thread, InitParameter, VirtualMachine};
1+
use super::{setting::Settings, thread, InitParameter, VirtualMachine};
22

33
/// The general interface for the VM
44
///
@@ -21,11 +21,11 @@ pub struct Interpreter {
2121
}
2222

2323
impl Interpreter {
24-
pub fn new(settings: PySettings, init: InitParameter) -> Self {
24+
pub fn new(settings: Settings, init: InitParameter) -> Self {
2525
Self::new_with_init(settings, |_| init)
2626
}
2727

28-
pub fn new_with_init<F>(settings: PySettings, init: F) -> Self
28+
pub fn new_with_init<F>(settings: Settings, init: F) -> Self
2929
where
3030
F: FnOnce(&mut VirtualMachine) -> InitParameter,
3131
{
@@ -56,7 +56,7 @@ impl Interpreter {
5656

5757
impl Default for Interpreter {
5858
fn default() -> Self {
59-
Self::new(PySettings::default(), InitParameter::External)
59+
Self::new(Settings::default(), InitParameter::External)
6060
}
6161
}
6262

vm/src/vm/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use std::{
4242

4343
pub use context::PyContext;
4444
pub use interpreter::Interpreter;
45-
pub use setting::PySettings;
45+
pub use setting::Settings;
4646

4747
// Objects are live when they are on stack, or referenced by a name (for now)
4848

@@ -77,7 +77,7 @@ struct ExceptionStack {
7777
}
7878

7979
pub struct PyGlobalState {
80-
pub settings: PySettings,
80+
pub settings: Settings,
8181
pub module_inits: stdlib::StdlibMap,
8282
pub frozen: HashMap<String, code::FrozenModule, ahash::RandomState>,
8383
pub stacksize: AtomicCell<usize>,
@@ -95,7 +95,7 @@ pub enum InitParameter {
9595

9696
impl VirtualMachine {
9797
/// Create a new `VirtualMachine` structure.
98-
fn new(settings: PySettings) -> VirtualMachine {
98+
fn new(settings: Settings) -> VirtualMachine {
9999
flame_guard!("new VirtualMachine");
100100
let ctx = PyContext::default();
101101

vm/src/vm/setting.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// Struct containing all kind of settings for the python vm.
22
#[non_exhaustive]
3-
pub struct PySettings {
3+
pub struct Settings {
44
/// -d command line switch
55
pub debug: bool,
66

@@ -61,9 +61,9 @@ pub struct PySettings {
6161
}
6262

6363
/// Sensible default settings.
64-
impl Default for PySettings {
64+
impl Default for Settings {
6565
fn default() -> Self {
66-
PySettings {
66+
Settings {
6767
debug: false,
6868
inspect: false,
6969
interactive: false,

wasm/lib/src/vm_class.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ use rustpython_vm::{
88
builtins::PyWeak,
99
compile::{self, Mode},
1010
scope::Scope,
11-
InitParameter, Interpreter, PyObjectRef, PyPayload, PyRef, PyResult, PySettings,
12-
VirtualMachine,
11+
InitParameter, Interpreter, PyObjectRef, PyPayload, PyRef, PyResult, Settings, VirtualMachine,
1312
};
1413
use std::{
1514
cell::RefCell,
@@ -42,7 +41,7 @@ fn init_window_module(vm: &VirtualMachine) -> PyObjectRef {
4241
impl StoredVirtualMachine {
4342
fn new(id: String, inject_browser_module: bool) -> StoredVirtualMachine {
4443
let mut scope = None;
45-
let interp = Interpreter::new_with_init(PySettings::default(), |vm| {
44+
let interp = Interpreter::new_with_init(Settings::default(), |vm| {
4645
vm.wasm_id = Some(id);
4746

4847
js_module::setup_js_module(vm);

0 commit comments

Comments
 (0)