Skip to content

Commit 09b9cda

Browse files
committed
corelib only expose pymodules
1 parent 6878200 commit 09b9cda

7 files changed

Lines changed: 14 additions & 13 deletions

File tree

‎vm/src/builtins/memory.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ use crate::common::{
77
};
88
use crate::{
99
bytesinner::bytes_to_hex,
10+
corelib::_struct::FormatSpec,
1011
function::{FuncArgs, OptionalArg},
1112
protocol::{BufferInternal, BufferOptions, PyBuffer},
1213
sliceable::{convert_slice, wrap_index, SequenceIndex},
1314
slots::{AsBuffer, Comparable, Hashable, PyComparisonOp, SlotConstructor},
14-
stdlib::pystruct::_struct::FormatSpec,
1515
utils::Either,
1616
IdProtocol, IntoPyObject, PyClassImpl, PyComparisonValue, PyContext, PyObjectRef, PyRef,
1717
PyResult, PyValue, TryFromBorrowedObject, TryFromObject, TypeProtocol, VirtualMachine,

‎vm/src/lib.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ mod bytesinner;
4848
pub mod byteslike;
4949
pub mod cformat;
5050
mod codecs;
51+
pub mod corelib;
5152
mod coroutine;
5253
#[cfg(any(unix, windows, target_os = "wasi"))]
5354
mod crt_fd;

‎vm/src/stdlib/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ mod sysconfigdata;
3838
mod syslog;
3939
#[cfg(feature = "threading")]
4040
mod thread;
41-
mod time;
41+
pub(crate) mod time;
4242
mod unicodedata;
4343
mod warnings;
4444
mod weakref;

‎vm/src/stdlib/nt.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,11 +421,11 @@ pub(crate) mod module {
421421
#[macro_export]
422422
macro_rules! suppress_iph {
423423
($e:expr) => {{
424-
let old = $crate::stdlib::nt::module::_set_thread_local_invalid_parameter_handler(
425-
$crate::stdlib::nt::module::silent_iph_handler,
424+
let old = $crate::corelib::nt::_set_thread_local_invalid_parameter_handler(
425+
$crate::corelib::nt::silent_iph_handler,
426426
);
427427
let ret = $e;
428-
$crate::stdlib::nt::module::_set_thread_local_invalid_parameter_handler(old);
428+
$crate::corelib::nt::_set_thread_local_invalid_parameter_handler(old);
429429
ret
430430
}};
431431
}

‎vm/src/stdlib/pystruct.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111

1212
#[pymodule]
13-
pub(crate) mod _struct {
13+
pub mod _struct {
1414
use crate::{
1515
builtins::{
1616
bytes::PyBytesRef, float, pybool::IntoPyBool, pystr::PyStr, pystr::PyStrRef,

‎vm/src/stdlib/select.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ fn sec_to_timeval(sec: f64) -> timeval {
150150
mod decl {
151151
use super::*;
152152
use crate::{
153-
exceptions::IntoPyException, function::OptionalOption, stdlib::time, utils::Either,
153+
corelib::time, exceptions::IntoPyException, function::OptionalOption, utils::Either,
154154
PyObjectRef, PyResult, VirtualMachine,
155155
};
156156

@@ -171,7 +171,7 @@ mod decl {
171171
return Err(vm.new_value_error("timeout must be positive".to_owned()));
172172
}
173173
}
174-
let deadline = timeout.map(|s| time::get_time(vm).unwrap() + s);
174+
let deadline = timeout.map(|s| time::time(vm).unwrap() + s);
175175

176176
let seq2set = |list| -> PyResult<(Vec<Selectable>, FdSet)> {
177177
let v = vm.extract_elements::<Selectable>(list)?;
@@ -210,7 +210,7 @@ mod decl {
210210
vm.check_signals()?;
211211

212212
if let Some(ref mut timeout) = timeout {
213-
*timeout = deadline.unwrap() - time::get_time(vm).unwrap();
213+
*timeout = deadline.unwrap() - time::time(vm).unwrap();
214214
if *timeout < 0.0 {
215215
r.clear();
216216
w.clear();

‎vm/src/stdlib/time.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ pub(crate) fn make_module(vm: &VirtualMachine) -> PyObjectRef {
1515
}
1616

1717
#[cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))]
18-
pub(crate) fn get_time(vm: &VirtualMachine) -> PyResult<f64> {
18+
fn get_time(vm: &VirtualMachine) -> PyResult<f64> {
1919
Ok(duration_since_system_now(vm)?.as_secs_f64())
2020
}
2121

2222
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
23-
pub(crate) fn get_time(_vm: &VirtualMachine) -> PyResult<f64> {
23+
fn get_time(_vm: &VirtualMachine) -> PyResult<f64> {
2424
use wasm_bindgen::prelude::*;
2525
#[wasm_bindgen]
2626
extern "C" {
@@ -41,7 +41,7 @@ fn duration_since_system_now(vm: &VirtualMachine) -> PyResult<std::time::Duratio
4141
}
4242

4343
#[pymodule(name = "time")]
44-
mod time {
44+
pub mod time {
4545
use crate::{
4646
builtins::{PyStrRef, PyTypeRef},
4747
function::{FuncArgs, OptionalArg},
@@ -84,7 +84,7 @@ mod time {
8484

8585
#[pyfunction(name = "perf_counter")] // TODO: fix
8686
#[pyfunction]
87-
fn time(vm: &VirtualMachine) -> PyResult<f64> {
87+
pub fn time(vm: &VirtualMachine) -> PyResult<f64> {
8888
super::get_time(vm)
8989
}
9090

0 commit comments

Comments
 (0)