Skip to content

Commit fb395bd

Browse files
committed
windows + signal
1 parent 4b9e446 commit fb395bd

File tree

8 files changed

+19
-38
lines changed

8 files changed

+19
-38
lines changed

stdlib/src/lib.rs

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// to allow `mod foo {}` in foo.rs; clippy thinks this is a mistake/misunderstanding of
2+
// how `mod` works, but we want this sometimes for pymodule declarations
3+
#![allow(clippy::module_inception)]
4+
15
#[macro_use]
26
extern crate rustpython_derive;
37

@@ -24,35 +28,27 @@ mod syslog;
2428
mod unicodedata;
2529
mod zlib;
2630

27-
// #[cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))]
28-
// #[macro_use]
29-
// pub(crate) mod os;
30-
3131
#[cfg(not(target_arch = "wasm32"))]
3232
mod faulthandler;
3333
#[cfg(any(unix, target_os = "wasi"))]
3434
mod fcntl;
35-
// #[cfg(windows)]
36-
// pub(crate) mod msvcrt;
3735
#[cfg(not(target_arch = "wasm32"))]
3836
mod multiprocessing;
3937
#[cfg(unix)]
4038
mod posixsubprocess;
41-
// // libc is missing constants on redox
39+
// libc is missing constants on redox
4240
#[cfg(all(unix, not(target_os = "redox")))]
4341
mod resource;
4442
// #[cfg(target_os = "macos")]
4543
// mod scproxy;
4644
#[cfg(not(target_arch = "wasm32"))]
4745
mod select;
46+
#[cfg(not(target_arch = "wasm32"))]
47+
pub(crate) mod signal;
4848
#[cfg(all(not(target_arch = "wasm32"), feature = "ssl"))]
4949
mod ssl;
5050
#[cfg(all(unix, not(target_os = "redox")))]
5151
mod termios;
52-
// #[cfg(windows)]
53-
// mod winapi;
54-
// #[cfg(windows)]
55-
// mod winreg;
5652

5753
use rustpython_common as common;
5854
use rustpython_vm as vm;
@@ -94,7 +90,6 @@ pub fn get_module_inits() -> StdlibMap {
9490
"pyexpat" => pyexpat::make_module,
9591
"_platform" => platform::make_module,
9692
"_random" => random::make_module,
97-
// "_struct" => pystruct::make_module,
9893
"unicodedata" => unicodedata::make_module,
9994
"zlib" => zlib::make_module,
10095
// crate::vm::sysmodule::sysconfigdata_name() => sysconfigdata::make_module,
@@ -116,6 +111,7 @@ pub fn get_module_inits() -> StdlibMap {
116111
{
117112
"_multiprocessing" => multiprocessing::make_module,
118113
"select" => select::make_module,
114+
"_signal" => signal::make_module,
119115
"_socket" => socket::make_module,
120116
"faulthandler" => faulthandler::make_module,
121117
}
@@ -133,12 +129,5 @@ pub fn get_module_inits() -> StdlibMap {
133129
"_posixsubprocess" => posixsubprocess::make_module,
134130
"syslog" => syslog::make_module,
135131
}
136-
// Windows-only
137-
#[cfg(windows)]
138-
{
139-
"msvcrt" => msvcrt::make_module,
140-
"_winapi" => winapi::make_module,
141-
"winreg" => winreg::make_module,
142-
}
143132
}
144133
}

vm/src/stdlib/signal.rs renamed to stdlib/src/signal.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::{PyObjectRef, VirtualMachine};
1+
use crate::vm::{PyObjectRef, VirtualMachine};
22

33
pub(crate) fn make_module(vm: &VirtualMachine) -> PyObjectRef {
4-
use crate::signal::NSIG;
4+
use crate::vm::signal::NSIG;
55
use _signal::{SIG_DFL, SIG_ERR, SIG_IGN};
66

77
let module = _signal::make_module(vm);
@@ -34,7 +34,7 @@ pub(crate) fn make_module(vm: &VirtualMachine) -> PyObjectRef {
3434

3535
#[pymodule]
3636
pub(crate) mod _signal {
37-
use crate::{
37+
use crate::vm::{
3838
exceptions::IntoPyException,
3939
signal::{check_signals, ANY_TRIGGERED, TRIGGERS},
4040
PyObjectRef, PyResult, TryFromBorrowedObject, VirtualMachine,
@@ -82,7 +82,7 @@ pub(crate) mod _signal {
8282
}
8383

8484
#[pyattr]
85-
pub use crate::signal::NSIG;
85+
pub use crate::vm::signal::NSIG;
8686

8787
#[pyattr]
8888
pub use libc::{SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, SIGTERM};
@@ -244,7 +244,7 @@ pub(crate) mod _signal {
244244
assert_in_range(signum, vm)?;
245245
let res = unsafe { siginterrupt(signum, flag) };
246246
if res < 0 {
247-
Err(crate::stdlib::os::errno_err(vm))
247+
Err(crate::vm::stdlib::os::errno_err(vm))
248248
} else {
249249
Ok(())
250250
}

stdlib/src/socket.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ impl PySocket {
509509
)
510510
};
511511
if res < 0 {
512-
return Err(super::os::errno_err(vm));
512+
return Err(crate::vm::stdlib::os::errno_err(vm));
513513
}
514514
}
515515
cfg_if::cfg_if! {

stdlib/src/ssl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::vm::{
44
ascii,
55
builtins::PyBaseExceptionRef,
66
builtins::{PyStrRef, PyType, PyTypeRef, PyWeak},
7-
exceptions::{create_exception_type, IntoPyException},
7+
exceptions::{self, create_exception_type, IntoPyException},
88
extend_module,
99
function::{ArgBytesLike, ArgMemoryBuffer, ArgStrOrBytesLike},
1010
function::{ArgCallable, OptionalArg},

vm/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ mod pyobjectrc;
6868
pub mod readline;
6969
pub mod scope;
7070
mod sequence;
71-
mod signal;
71+
pub mod signal;
7272
pub mod sliceable;
7373
pub mod slots;
7474
pub mod stdlib;

vm/src/signal.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use crate::{PyObjectRef, PyResult, VirtualMachine};
22
use std::sync::atomic::{AtomicBool, Ordering};
33

44
pub const NSIG: usize = 64;
5-
pub(crate) static ANY_TRIGGERED: AtomicBool = AtomicBool::new(false);
5+
pub static ANY_TRIGGERED: AtomicBool = AtomicBool::new(false);
66
// hack to get around const array repeat expressions, rust issue #79270
77
#[allow(clippy::declare_interior_mutable_const)]
88
const ATOMIC_FALSE: AtomicBool = AtomicBool::new(false);
9-
pub(crate) static TRIGGERS: [AtomicBool; NSIG] = [ATOMIC_FALSE; NSIG];
9+
pub static TRIGGERS: [AtomicBool; NSIG] = [ATOMIC_FALSE; NSIG];
1010

1111
#[cfg_attr(feature = "flame-it", flame)]
1212
#[inline(always)]

vm/src/stdlib/mod.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ mod itertools;
1111
mod marshal;
1212
mod operator;
1313
pub(crate) mod pystruct;
14-
// mod random;
1514
// TODO: maybe make this an extension module, if we ever get those
1615
// mod re;
1716
mod sre;
@@ -43,8 +42,6 @@ pub use posix_compat as posix;
4342
pub(crate) mod msvcrt;
4443
#[cfg(all(unix, not(any(target_os = "android", target_os = "redox"))))]
4544
mod pwd;
46-
#[cfg(not(target_arch = "wasm32"))]
47-
pub(crate) mod signal;
4845
#[cfg(windows)]
4946
mod winapi;
5047
#[cfg(windows)]
@@ -111,11 +108,6 @@ pub fn get_module_inits() -> StdlibMap {
111108
"posix" => posix::make_module,
112109
// "fcntl" => fcntl::make_module,
113110
}
114-
// disable some modules on WASM
115-
#[cfg(not(target_arch = "wasm32"))]
116-
{
117-
"_signal" => signal::make_module,
118-
}
119111
#[cfg(all(feature = "threading", not(target_arch = "wasm32")))]
120112
{
121113
"_thread" => thread::make_module,

vm/src/stdlib/msvcrt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::os::errno_err;
2-
use crate::vm::{
2+
use crate::{
33
builtins::{PyBytes, PyStrRef},
44
suppress_iph, PyObjectRef, PyRef, PyResult, VirtualMachine,
55
};

0 commit comments

Comments
 (0)