Skip to content

Commit 986450d

Browse files
committed
vm::sysmodule -> vm::stdlib::sys
1 parent e9c098b commit 986450d

8 files changed

Lines changed: 17 additions & 17 deletions

File tree

‎src/lib.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ extern crate log;
4545

4646
use clap::{App, AppSettings, Arg, ArgMatches};
4747
use rustpython_vm::{
48-
builtins::PyInt, compile, exceptions::print_exception, match_class, scope::Scope, sysmodule,
48+
builtins::PyInt, compile, exceptions::print_exception, match_class, scope::Scope, stdlib::sys,
4949
InitParameter, Interpreter, ItemProtocol, PyResult, PySettings, TypeProtocol, VirtualMachine,
5050
};
5151

@@ -158,10 +158,10 @@ where
158158
}
159159

160160
fn flush_std(vm: &VirtualMachine) {
161-
if let Ok(stdout) = sysmodule::get_stdout(vm) {
161+
if let Ok(stdout) = sys::get_stdout(vm) {
162162
let _ = vm.call_method(&stdout, "flush", ());
163163
}
164-
if let Ok(stderr) = sysmodule::get_stderr(vm) {
164+
if let Ok(stderr) = sys::get_stderr(vm) {
165165
let _ = vm.call_method(&stderr, "flush", ());
166166
}
167167
}

‎vm/src/builtins/make_module.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ mod decl {
2929
readline::{Readline, ReadlineResult},
3030
scope::Scope,
3131
slots::PyComparisonOp,
32-
sysmodule,
32+
stdlib::sys,
3333
utils::Either,
3434
IdProtocol, ItemProtocol, PyArithmaticValue, PyClassImpl, PyObjectRef, PyRef, PyResult,
3535
PyValue, TryFromObject, TypeProtocol, VirtualMachine,
@@ -361,9 +361,9 @@ mod decl {
361361

362362
#[pyfunction]
363363
fn input(prompt: OptionalArg<PyStrRef>, vm: &VirtualMachine) -> PyResult {
364-
let stdin = sysmodule::get_stdin(vm)?;
365-
let stdout = sysmodule::get_stdout(vm)?;
366-
let stderr = sysmodule::get_stderr(vm)?;
364+
let stdin = sys::get_stdin(vm)?;
365+
let stdout = sys::get_stdout(vm)?;
366+
let stderr = sys::get_stderr(vm)?;
367367

368368
let _ = vm.call_method(&stderr, "flush", ());
369369

@@ -650,7 +650,7 @@ mod decl {
650650
pub fn print(objects: PosArgs, options: PrintOptions, vm: &VirtualMachine) -> PyResult<()> {
651651
let file = match options.file {
652652
Some(f) => f,
653-
None => sysmodule::get_stdout(vm)?,
653+
None => sys::get_stdout(vm)?,
654654
};
655655
let write = |obj: PyStrRef| vm.call_method(&file, "write", (obj,));
656656

‎vm/src/exceptions.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::builtins::tuple::{PyTuple, PyTupleRef};
66
use crate::common::lock::PyRwLock;
77
use crate::function::{ArgIterable, FuncArgs};
88
use crate::py_io::{self, Write};
9-
use crate::sysmodule;
9+
use crate::stdlib::sys;
1010
use crate::types::create_type_with_slots;
1111
use crate::{
1212
IdProtocol, IntoPyObject, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue,
@@ -171,7 +171,7 @@ pub fn chain<T>(e1: PyResult<()>, e2: PyResult<T>) -> PyResult<T> {
171171
/// Print exception chain by calling sys.excepthook
172172
pub fn print_exception(vm: &VirtualMachine, exc: PyBaseExceptionRef) {
173173
let write_fallback = |exc, errstr| {
174-
if let Ok(stderr) = sysmodule::get_stderr(vm) {
174+
if let Ok(stderr) = sys::get_stderr(vm) {
175175
let mut stderr = py_io::PyWriter(stderr, vm);
176176
// if this fails stderr might be closed -- ignore it
177177
let _ = writeln!(stderr, "{}", errstr);

‎vm/src/lib.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ mod sequence;
7272
mod sliceable;
7373
pub mod slots;
7474
pub mod stdlib;
75-
pub mod sysmodule;
7675
pub mod types;
7776
pub mod utils;
7877
mod version;

‎vm/src/stdlib/mod.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ mod select;
8181
pub(crate) mod signal;
8282
#[cfg(all(not(target_arch = "wasm32"), feature = "ssl"))]
8383
mod ssl;
84+
pub mod sys;
8485
#[cfg(all(unix, not(target_os = "redox")))]
8586
mod termios;
8687
#[cfg(windows)]
@@ -146,7 +147,7 @@ pub fn get_module_inits() -> StdlibMap {
146147
"unicodedata" => unicodedata::make_module,
147148
"_warnings" => warnings::make_module,
148149
"zlib" => zlib::make_module,
149-
crate::sysmodule::sysconfigdata_name() => sysconfigdata::make_module,
150+
sys::sysconfigdata_name() => sysconfigdata::make_module,
150151
}
151152
// parser related modules:
152153
#[cfg(feature = "rustpython-ast")]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ pub fn get_stderr(vm: &VirtualMachine) -> PyResult {
358358
/// # Usage
359359
///
360360
/// ```rust,ignore
361-
/// writeln!(sysmodule::PyStderr(vm), "foo bar baz :)");
361+
/// writeln!(sys::PyStderr(vm), "foo bar baz :)");
362362
/// ```
363363
///
364364
/// Unlike writing to a `std::io::Write` with the `write[ln]!()` macro, there's no error condition here;

‎vm/src/stdlib/sysconfigdata.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::sysmodule::MULTIARCH;
1+
use super::sys::MULTIARCH;
22
use crate::{IntoPyObject, ItemProtocol, PyObjectRef, VirtualMachine};
33

44
pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {

‎vm/src/vm.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::function::{FuncArgs, IntoFuncArgs};
3131
use crate::scope::Scope;
3232
use crate::slots::PyComparisonOp;
3333
use crate::utils::Either;
34-
use crate::{builtins, bytecode, frozen, import, iterator, stdlib, sysmodule};
34+
use crate::{builtins, bytecode, frozen, import, iterator, stdlib, stdlib::sys};
3535
use crate::{
3636
IdProtocol, IntoPyObject, ItemProtocol, PyArithmaticValue, PyContext, PyLease, PyMethod,
3737
PyObject, PyObjectRef, PyRef, PyRefExact, PyResult, PyValue, TryFromObject, TryIntoRef,
@@ -327,7 +327,7 @@ impl VirtualMachine {
327327
}
328328

329329
builtins::make_module(self, self.builtins.clone());
330-
sysmodule::make_module(self, self.sys_module.clone(), self.builtins.clone());
330+
sys::make_module(self, self.sys_module.clone(), self.builtins.clone());
331331

332332
let mut inner_init = || -> PyResult<()> {
333333
#[cfg(not(target_arch = "wasm32"))]
@@ -476,7 +476,7 @@ impl VirtualMachine {
476476
if let Err(e) = self.invoke(&func, args) {
477477
last_exc = Some(e.clone());
478478
if !e.isinstance(&self.ctx.exceptions.system_exit) {
479-
writeln!(sysmodule::PyStderr(self), "Error in atexit._run_exitfuncs:");
479+
writeln!(sys::PyStderr(self), "Error in atexit._run_exitfuncs:");
480480
exceptions::print_exception(self, e);
481481
}
482482
}

0 commit comments

Comments
 (0)