diff --git a/Cargo.lock b/Cargo.lock index d66e1bb33..ccd224f4f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -818,6 +818,12 @@ dependencies = [ "regex", ] +[[package]] +name = "env_home" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f84e12ccf0a7ddc17a6c41c93326024c42920d7ee630d04950e6926645c0fe" + [[package]] name = "env_logger" version = "0.11.8" @@ -872,7 +878,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce92ff622d6dadf7349484f42c93271a0d49b7cc4d466a936405bacbe10aa78" dependencies = [ "cfg-if", - "rustix 1.0.5", + "rustix", "windows-sys 0.59.0", ] @@ -966,7 +972,7 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed7131e57abbde63513e0e6636f76668a1ca9798dcae2df4e283cae9ee83859e" dependencies = [ - "rustix 1.0.5", + "rustix", "windows-targets 0.52.6", ] @@ -1396,12 +1402,6 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" -[[package]] -name = "linux-raw-sys" -version = "0.4.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" - [[package]] name = "linux-raw-sys" version = "0.9.3" @@ -2272,19 +2272,6 @@ version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" -[[package]] -name = "rustix" -version = "0.38.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" -dependencies = [ - "bitflags 2.9.0", - "errno", - "libc", - "linux-raw-sys 0.4.15", - "windows-sys 0.59.0", -] - [[package]] name = "rustix" version = "1.0.5" @@ -2294,7 +2281,7 @@ dependencies = [ "bitflags 2.9.0", "errno", "libc", - "linux-raw-sys 0.9.3", + "linux-raw-sys", "windows-sys 0.59.0", ] @@ -2539,7 +2526,7 @@ dependencies = [ "paste", "puruspe", "rand_core 0.9.3", - "rustix 0.38.44", + "rustix", "rustpython-common", "rustpython-derive", "rustpython-vm", @@ -2613,7 +2600,7 @@ dependencies = [ "ruff_python_parser", "ruff_source_file", "ruff_text_size", - "rustix 0.38.44", + "rustix", "rustpython-codegen", "rustpython-common", "rustpython-compiler", @@ -3427,13 +3414,13 @@ dependencies = [ [[package]] name = "which" -version = "6.0.3" +version = "7.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ee928febd44d98f2f459a4a79bd4d928591333a494a10a868418ac1b39cf1f" +checksum = "24d643ce3fd3e5b54854602a080f34fb10ab75e0b813ee32d00ca2b44fa74762" dependencies = [ "either", - "home", - "rustix 0.38.44", + "env_home", + "rustix", "winsafe", ] diff --git a/Cargo.toml b/Cargo.toml index fe444b196..621c25517 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -186,7 +186,7 @@ proc-macro2 = "1.0.93" quote = "1.0.38" rand = "0.9" rand_core = { version = "0.9", features = ["os_rng"] } -rustix = { version = "0.38", features = ["event"] } +rustix = { version = "1.0", features = ["event"] } rustyline = "15.0.0" serde = { version = "1.0.133", default-features = false } schannel = "0.1.27" diff --git a/stdlib/src/select.rs b/stdlib/src/select.rs index f89a6c4f0..f600d60ed 100644 --- a/stdlib/src/select.rs +++ b/stdlib/src/select.rs @@ -519,7 +519,7 @@ mod decl { use rustix::event::epoll::{self, EventData, EventFlags}; use std::ops::Deref; use std::os::fd::{AsRawFd, IntoRawFd, OwnedFd}; - use std::time::{Duration, Instant}; + use std::time::Instant; #[pyclass(module = "select", name = "epoll")] #[derive(Debug, rustpython_vm::PyPayload)] @@ -636,12 +636,11 @@ mod decl { let poll::TimeoutArg(timeout) = args.timeout; let maxevents = args.maxevents; - let make_poll_timeout = |d: Duration| i32::try_from(d.as_millis()); - let mut poll_timeout = match timeout { - Some(d) => make_poll_timeout(d) - .map_err(|_| vm.new_overflow_error("timeout is too large".to_owned()))?, - None => -1, - }; + let mut poll_timeout = + timeout + .map(rustix::event::Timespec::try_from) + .transpose() + .map_err(|_| vm.new_overflow_error("timeout is too large".to_owned()))?; let deadline = timeout.map(|d| Instant::now() + d); let maxevents = match maxevents { @@ -654,19 +653,24 @@ mod decl { _ => maxevents as usize, }; - let mut events = epoll::EventVec::with_capacity(maxevents); + let mut events = Vec::::with_capacity(maxevents); let epoll = &*self.get_epoll(vm)?; loop { - match epoll::wait(epoll, &mut events, poll_timeout) { - Ok(()) => break, + events.clear(); + match epoll::wait( + epoll, + rustix::buffer::spare_capacity(&mut events), + poll_timeout.as_ref(), + ) { + Ok(_) => break, Err(rustix::io::Errno::INTR) => vm.check_signals()?, Err(e) => return Err(e.into_pyexception(vm)), } if let Some(deadline) = deadline { if let Some(new_timeout) = deadline.checked_duration_since(Instant::now()) { - poll_timeout = make_poll_timeout(new_timeout).unwrap(); + poll_timeout = Some(new_timeout.try_into().unwrap()); } else { break; } diff --git a/vm/Cargo.toml b/vm/Cargo.toml index 125c263da..1fdd700b7 100644 --- a/vm/Cargo.toml +++ b/vm/Cargo.toml @@ -101,7 +101,7 @@ uname = "0.1.1" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] rustyline = { workspace = true } -which = "6" +which = "7" errno = "0.3" widestring = { workspace = true }