8000 Update deps by coolreader18 · Pull Request #5417 · RustPython/RustPython · GitHub
[go: up one dir, main page]

Skip to content

Update deps #5417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,130 changes: 491 additions & 639 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions Cargo.toml
8000
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ rustyline = { workspace = true }

[dev-dependencies]
criterion = { version = "0.3.5", features = ["html_reports"] }
pyo3 = { version = "0.20.2", features = ["auto-initialize"] }
pyo3 = { version = "0.22", features = ["auto-initialize"] }

[[bench]]
name = "execution"
Expand Down Expand Up @@ -105,7 +105,7 @@ members = [
version = "0.4.0"
authors = ["RustPython Team"]
edition = "2021"
rust-version = "1.78.0"
rust-version = "1.80.0"
repository = "https://github.com/RustPython/RustPython"
license = "MIT"

Expand Down Expand Up @@ -143,7 +143,7 @@ ahash = "0.8.11"
ascii = "1.0"
atty = "0.2.14"
bitflags = "2.4.1"
bstr = "0.2.17"
bstr = "1"
cfg-if = "1.0"
chrono = "0.4.37"
crossbeam-utils = "0.8.19"
Expand All @@ -158,7 +158,7 @@ is-macro = "0.3.0"
junction = "1.0.0"
libc = "0.2.153"
log = "0.4.16"
nix = { version = "0.27", features = ["fs", "user", "process", "term", "time", "signal", "ioctl", "socket", "sched", "zerocopy", "dir", "hostname", "net", "poll"] }
nix = { version = "0.29", features = ["fs", "user", "process", "term", "time", "signal", "ioctl", "socket", "sched", "zerocopy", "dir", "hostname", "net", "poll"] }
malachite-bigint = "0.2.0"
malachite-q = "0.4.4"
malachite-base = "0.4.4"
Expand All @@ -176,6 +176,8 @@ rustyline = "14.0.0"
serde = { version = "1.0.133", default-features = false }
schannel = "0.1.22"
static_assertions = "1.1"
strum = "0.26"
strum_macros = "0.26"
syn = "1.0.109"
thiserror = "1.0"
thread_local = "1.1.4"
Expand Down
9 changes: 5 additions & 4 deletions benches/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use std::path::Path;
fn bench_cpython_code(b: &mut Bencher, source: &str) {
pyo3::Python::with_gil(|py| {
b.iter(|| {
let module =
pyo3::types::PyModule::from_code(py, source, "", "").expect("Error running source");
let module = pyo3::types::PyModule::from_code_bound(py, source, "", "")
.expect("Error running source");
black_box(module);
})
})
Expand Down Expand Up @@ -53,9 +53,10 @@ pub fn benchmark_file_parsing(group: &mut BenchmarkGroup<WallTime>, name: &str,
b.iter(|| ast::Suite::parse(contents, name).unwrap())
});
group.bench_function(BenchmarkId::new("cpython", name), |b| {
use pyo3::types::PyAnyMethods;
pyo3::Python::with_gil(|py| {
let builtins =
pyo3::types::PyModule::import(py, "builtins").expect("Failed to import builtins");
let builtins = pyo3::types::PyModule::import_bound(py, "builtins")
.expect("Failed to import builtins");
let compile = builtins.getattr("compile").expect("no compile in builtins");
b.iter(|| {
let x = compile
Expand Down
20 changes: 12 additions & 8 deletions benches/microbenchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use criterion::{
criterion_group, criterion_main, measurement::WallTime, BatchSize, BenchmarkGroup, BenchmarkId,
Criterion, Throughput,
};
use pyo3::types::PyAnyMethods;
use rustpython_compiler::Mode;
use rustpython_vm::{AsObject, Interpreter, PyResult, Settings};
use std::{
Expand Down Expand Up @@ -44,25 +45,28 @@ fn bench_cpython_code(group: &mut BenchmarkGroup<WallTime>, bench: &MicroBenchma

// Grab the exec function in advance so we don't have lookups in the hot code
let builtins =
pyo3::types::PyModule::import(py, "builtins").expect("Failed to import builtins");
pyo3::types::PyModule::import_bound(py, "builtins").expect("Failed to import builtins");
let exec = builtins.getattr("exec").expect("no exec in builtins");

let bench_func = |(globals, locals): &mut (&pyo3::types::PyDict, &pyo3::types::PyDict)| {
let res = exec.call((code, &*globals, &*locals), None);
let bench_func = |(globals, locals): &mut (
pyo3::Bound<pyo3::types::PyDict>,
pyo3::Bound<pyo3::types::PyDict>,
)| {
let res = exec.call((&code, &*globals, &*locals), None);
if let Err(e) = res {
e.print(py);
panic!("Error running microbenchmark")
}
};

let bench_setup = |iterations| {
let globals = pyo3::types::PyDict::new(py);
let locals = pyo3::types::PyDict::new(py);
let globals = pyo3::types::PyDict::new_bound(py);
let locals = pyo3::types::PyDict::new_bound(py);
if let Some(idx) = iterations {
globals.set_item("ITERATIONS", idx).unwrap();
}

let res = exec.call((setup_code, &globals, &locals), None);
let res = exec.call((&setup_code, &globals, &locals), None);
if let Err(e) = res {
e.print(py);
panic!("Error running microbenchmark setup code")
Expand Down Expand Up @@ -93,9 +97,9 @@ fn cpy_compile_code<'a>(
py: pyo3::Python<'a>,
code: &str,
name: &str,
) -> pyo3::PyResult<&'a pyo3::types::PyCode> {
) -> pyo3::PyResult<pyo3::Bound<'a, pyo3::types::PyCode>> {
let builtins =
pyo3::types::PyModule::import(py, "builtins").expect("Failed to import builtins");
pyo3::types::PyModule::import_bound(py, "builtins").expect("Failed to import builtins");
let compile = builtins.getattr("compile").expect("no compile in builtins");
compile.call1((code, name, "exec"))?.extract()
}
Expand Down
1 change: 0 additions & 1 deletion common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ rustpython-format = { workspace = true }

ascii = { workspace = true }
bitflags = { workspace = true }
bstr = { workspace = true }
cfg-if = { workspace = true }
itertools = { workspace = true }
libc = { workspace = true }
Expand Down
3 changes: 1 addition & 2 deletions common/src/int.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use bstr::ByteSlice;
use malachite_base::{num::conversion::traits::RoundingInto, rounding_modes::RoundingMode};
use malachite_bigint::{BigInt, BigUint, Sign};
use malachite_q::Rational;
Expand Down Expand Up @@ -32,7 +31,7 @@ pub fn float_to_ratio(value: f64) -> Option<(BigInt, BigInt)> {

pub fn bytes_to_int(lit: &[u8], mut base: u32) -> Option<BigInt> {
// split sign
let mut lit = lit.trim();
let mut lit = lit.trim_ascii();
let sign = match lit.first()? {
b'+' => Some(Sign::Plus),
b'-' => Some(Sign::Minus),
Expand Down
2 changes: 2 additions & 0 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! A crate to hold types and functions common to all rustpython components.

#![cfg_attr(target_os = "redox", feature(byte_slice_trim_ascii))]

#[macro_use]
mod macros;
pub use macros::*;
Expand Down
7 changes: 4 additions & 3 deletions stdlib/src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1842,15 +1842,16 @@ mod _socket {
#[cfg(unix)]
{
use nix::poll::*;
use std::os::fd::AsFd;
let events = match kind {
SelectKind::Read => PollFlags::POLLIN,
SelectKind::Write => PollFlags::POLLOUT,
SelectKind::Connect => PollFlags::POLLOUT | PollFlags::POLLERR,
};
let mut pollfd = [PollFd::new(sock, events)];
let mut pollfd = [PollFd::new(sock.as_fd(), events)];
let timeout = match interval {
Some(d) => d.as_millis() as _,
None => -1,
Some(d) => d.try_into().unwrap_or(PollTimeout::MAX),
None => PollTimeout::NONE,
};
let ret = poll(&mut pollfd, timeout)?;
Ok(ret == 0)
Expand Down
12 changes: 6 additions & 6 deletions vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ memchr = { workspace = true }

caseless = "0.2.1"
flamer = { version = "0.4", optional = true }
half = "1.8.2"
half = "2"
memoffset = "0.9.1"
optional = "0.5.0"
result-like = "0.4.6"
Expand All @@ -94,12 +94,12 @@ unic-ucd-ident = "0.9.0"
rustix = { workspace = true }
exitcode = "1.1.2"
uname = "0.1.1"
strum = "0.24.0"
strum_macros = "0.24.0"
strum = { workspace = true }
strum_macros = { workspace = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
rustyline = { workspace = true }
which = "4.2.5"
which = "6"

[target.'cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))'.dependencies]
num_cpus = "1.13.1"
Expand All @@ -108,7 +108,7 @@ num_cpus = "1.13.1"
junction = { workspace = true }
schannel = { workspace = true }
widestring = { workspace = true }
winreg = "0.10.1"
winreg = "0.52"

[target.'cfg(windows)'.dependencies.windows]
version = "0.52.0"
Expand Down Expand Up @@ -152,4 +152,4 @@ itertools = { workspace = true }
rustc_version = "0.4.0"

[lints]
workspace = true
workspace = true
3 changes: 2 additions & 1 deletion vm/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,8 @@ make_pack_float!(f64);
impl Packable for f16 {
fn pack<E: ByteOrder>(vm: &VirtualMachine, arg: PyObjectRef, data: &mut [u8]) -> PyResult<()> {
let f_64 = *ArgIntoFloat::try_from_object(vm, arg)?;
let f_16 = f16::from_f64(f_64);
// "from_f64 should be preferred in any non-`const` context" except it gives the wrong result :/
let f_16 = f16::from_f64_const(f_64);
if f_16.is_infinite() != f_64.is_infinite() {
return Err(vm.new_overflow_error("float too large to pack with e format".to_owned()));
}
Expand Down
15 changes: 14 additions & 1 deletion vm/src/builtins/complex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,27 @@ fn inner_pow(v1: Complex64, v2: Complex64, vm: &VirtualMachine) -> PyResult<Comp
};
}

let ans = v1.powc(v2);
let ans = powc(v1, v2);
if ans.is_infinite() && !(v1.is_infinite() || v2.is_infinite()) {
Err(vm.new_overflow_error("complex exponentiation overflow".to_owned()))
} else {
Ok(ans)
}
}

// num-complex changed their powc() implementation in 0.4.4, making it incompatible
// with what the regression tests expect. this is that old formula.
fn powc(a: Complex64, exp: Complex64) -> Complex64 {
let (r, theta) = a.to_polar();
if r.is_zero() {
return Complex64::new(r, r);
}
Complex64::from_polar(
r.powf(exp.re) * (-exp.im * theta).exp(),
exp.re * theta + exp.im * r.ln(),
)
}

impl Constructor for PyComplex {
type Args = ComplexArgs;

Expand Down
2 changes: 1 addition & 1 deletion vm/src/builtins/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ fn try_int_radix(obj: &PyObject, base: u32, vm: &VirtualMachine) -> PyResult<Big

let opt = match_class!(match obj.to_owned() {
string @ PyStr => {
let s = string.as_str();
let s = string.as_str().trim();
bytes_to_int(s.as_bytes(), base)
}
bytes @ PyBytes => {
Expand Down
2 changes: 1 addition & 1 deletion vm/src/protocol/number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl PyObject {
))
})
} else if let Some(s) = self.payload::<PyStr>() {
try_convert(self, s.as_str().as_bytes(), vm)
try_convert(self, s.as_str().trim().as_bytes(), vm)
} else if let Some(bytes) = self.payload::<PyBytes>() {
try_convert(self, bytes, vm)
} else if let Some(bytearray) = self.payload::<PyByteArray>() {
Expand Down
33 changes: 14 additions & 19 deletions vm/src/stdlib/posix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,9 @@ pub mod module {
};

let flag = if follow_symlinks.0 {
nix::unistd::FchownatFlags::FollowSymlink
nix::fcntl::AtFlags::empty()
} else {
nix::unistd::FchownatFlags::NoFollowSymlink
nix::fcntl::AtFlags::AT_SYMLINK_NOFOLLOW
};

let dir_fd = dir_fd.get_opt();
Expand Down Expand Up @@ -631,10 +631,10 @@ pub mod module {
#[cfg(not(target_os = "redox"))]
#[pyfunction]
fn nice(increment: i32, vm: &VirtualMachine) -> PyResult<i32> {
use nix::errno::{errno, Errno};
use nix::errno::Errno;
Errno::clear();
let res = unsafe { libc::nice(increment) };
if res == -1 && errno() != 0 {
if res == -1 && Errno::last_raw() != 0 {
Err(errno_err(vm))
} else {
Ok(res)
Expand Down Expand Up @@ -877,16 +877,11 @@ pub mod module {
}

#[pyfunction]
fn pipe(vm: &VirtualMachine) -> PyResult<(RawFd, RawFd)> {
use nix::unistd::close;
fn pipe(vm: &VirtualMachine) -> PyResult<(OwnedFd, OwnedFd)> {
use nix::unistd::pipe;
let (rfd, wfd) = pipe().map_err(|err| err.into_pyexception(vm))?;
set_inheritable(rfd, false, vm)
.and_then(|_| set_inheritable(wfd, false, vm))
.inspect_err(|_| {
let _ = close(rfd);
let _ = close(wfd);
})?;
set_inheritable(rfd.as_raw_fd(), false, vm)?;
set_inheritable(wfd.as_raw_fd(), false, vm)?;
Ok((rfd, wfd))
}

Expand All @@ -901,7 +896,7 @@ pub mod module {
target_os = "openbsd"
))]
#[pyfunction]
fn pipe2(flags: libc::c_int, vm: &VirtualMachine) -> PyResult<(RawFd, RawFd)> {
fn pipe2(flags: libc::c_int, vm: &VirtualMachine) -> PyResult<(OwnedFd, OwnedFd)> {
let oflags = fcntl::OFlag::from_bits_truncate(flags);
nix::unistd::pipe2(oflags).map_err(|err| err.into_pyexception(vm))
}
Expand Down Expand Up @@ -1227,7 +1222,7 @@ pub mod module {
}

#[pyfunction]
fn ttyname(fd: i32, vm: &VirtualMachine) -> PyResult {
fn ttyname(fd: BorrowedFd<'_>, vm: &VirtualMachine) -> PyResult {
let name = unistd::ttyname(fd).map_err(|e| e.into_pyexception(vm))?;
let name = name.into_os_string().into_string().unwrap();
Ok(vm.ctx.new_str(name).into())
Expand Down Expand Up @@ -1756,10 +1751,10 @@ pub mod module {
who: PriorityWhoType,
vm: &VirtualMachine,
) -> PyResult {
use nix::errno::{errno, Errno};
use nix::errno::Errno;
Errno::clear();
let retval = unsafe { libc::getpriority(which, who) };
if errno() != 0 {
if Errno::last_raw() != 0 {
Err(errno_err(vm))
} else {
Ok(vm.ctx.new_int(retval).into())
Expand Down Expand Up @@ -1973,10 +1968,10 @@ pub mod module {
PathconfName(name): PathconfName,
vm: &VirtualMachine,
) -> PyResult<Option<libc::c_long>> {
use nix::errno::{self, Errno};
use nix::errno::Errno;

Errno::clear();
debug_assert_eq!(errno::errno(), 0);
debug_assert_eq!(Errno::last_raw(), 0);
let raw = match &path {
OsPathOrFd::Path(path) => {
let path = path.clone().into_cstring(vm)?;
Expand All @@ -1986,7 +1981,7 @@ pub mod module {
};

if raw == -1 {
if errno::errno() == 0 {
if Errno::last_raw() == 0 {
Ok(None)
} else {
Err(IOErrorBuilder::with_filename(
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ mod platform {

let ts = TimeSpec::from(dur);
let res = unsafe { libc::nanosleep(ts.as_ref(), std::ptr::null_mut()) };
let interrupted = res == -1 && nix::errno::errno() == libc::EINTR;
let interrupted = res == -1 && nix::Error::last_raw() == libc::EINTR;

if interrupted {
vm.check_signals()?;
Expand Down
Loading
Loading
0