Skip to content

Commit 6c1842c

Browse files
committed
Apply patches
1 parent 221dfc2 commit 6c1842c

4 files changed

Lines changed: 28 additions & 8 deletions

File tree

crates/stdlib/src/compression.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ impl<D: Decompressor> DecompressState<D> {
296296
self.eof
297297
}
298298

299-
pub fn decompressor(&self) -> &D {
299+
#[cfg_attr(target_os = "android", allow(dead_code))]
300+
pub const fn decompressor(&self) -> &D {
300301
&self.decompress
301302
}
302303

crates/vm/src/stdlib/os.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,7 @@ pub(super) mod _os {
12151215
}
12161216
}
12171217

1218+
#[cfg_attr(target_env = "musl", allow(deprecated))]
12181219
#[derive(Debug, FromArgs)]
12191220
#[pystruct_sequence_data]
12201221
struct StatResultData {
@@ -1226,12 +1227,15 @@ pub(super) mod _os {
12261227
pub st_gid: PyIntRef,
12271228
pub st_size: PyIntRef,
12281229
// Indices 7-9: integer seconds
1230+
#[cfg_attr(target_env = "musl", allow(deprecated))]
12291231
#[pyarg(positional, default)]
12301232
#[pystruct_sequence(unnamed)]
12311233
pub st_atime_int: libc::time_t,
1234+
#[cfg_attr(target_env = "musl", allow(deprecated))]
12321235
#[pyarg(positional, default)]
12331236
#[pystruct_sequence(unnamed)]
12341237
pub st_mtime_int: libc::time_t,
1238+
#[cfg_attr(target_env = "musl", allow(deprecated))]
12351239
#[pyarg(positional, default)]
12361240
#[pystruct_sequence(unnamed)]
12371241
pub st_ctime_int: libc::time_t,

crates/vm/src/stdlib/posix.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ pub mod module {
5151
use nix::{
5252
errno::Errno,
5353
fcntl,
54-
sys::signal,
5554
unistd::{self, Gid, Pid, Uid},
5655
};
5756
use rustpython_common::os::ffi::OsStringExt;
@@ -1530,6 +1529,8 @@ pub mod module {
15301529
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "macos"))]
15311530
impl PosixSpawnArgs {
15321531
fn spawn(self, spawnp: bool, vm: &VirtualMachine) -> PyResult<libc::pid_t> {
1532+
use nix::sys::signal;
1533+
15331534
use crate::TryFromBorrowedObject;
15341535

15351536
let path = self
@@ -2566,11 +2567,8 @@ pub mod module {
25662567
#[pymodule(sub)]
25672568
mod posix_sched {
25682569
use crate::{
2569-
AsObject, Py, PyObjectRef, PyResult, VirtualMachine,
2570-
builtins::{PyInt, PyTupleRef},
2571-
convert::ToPyObject,
2572-
function::FuncArgs,
2573-
types::PyStructSequence,
2570+
AsObject, Py, PyObjectRef, PyResult, VirtualMachine, builtins::PyTupleRef,
2571+
convert::ToPyObject, function::FuncArgs, types::PyStructSequence,
25742572
};
25752573

25762574
#[derive(FromArgs)]
@@ -2629,7 +2627,10 @@ mod posix_sched {
26292627

26302628
#[cfg(not(target_env = "musl"))]
26312629
fn convert_sched_param(obj: &PyObjectRef, vm: &VirtualMachine) -> PyResult<libc::sched_param> {
2632-
use crate::{builtins::PyTuple, class::StaticType};
2630+
use crate::{
2631+
builtins::{PyInt, PyTuple},
2632+
class::StaticType,
2633+
};
26332634
if !obj.fast_isinstance(PySchedParam::static_type()) {
26342635
return Err(vm.new_type_error("must have a sched_param object".to_owned()));
26352636
}
@@ -2653,6 +2654,7 @@ mod posix_sched {
26532654
}
26542655
}
26552656

2657+
#[cfg(not(target_env = "musl"))]
26562658
#[derive(FromArgs)]
26572659
struct SchedSetschedulerArgs {
26582660
#[pyarg(positional)]
@@ -2692,6 +2694,7 @@ mod posix_sched {
26922694
))
26932695
}
26942696

2697+
#[cfg(not(target_env = "musl"))]
26952698
#[derive(FromArgs)]
26962699
struct SchedSetParamArgs {
26972700
#[pyarg(positional)]

crates/vm/src/stdlib/time.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,21 +998,25 @@ mod decl {
998998
}
999999

10001000
#[cfg(any(unix, windows))]
1001+
#[cfg_attr(target_env = "musl", allow(deprecated))]
10011002
fn pyobj_to_time_t(value: Either<f64, i64>, vm: &VirtualMachine) -> PyResult<libc::time_t> {
10021003
match value {
10031004
Either::A(float) => {
10041005
if !float.is_finite() {
10051006
return Err(vm.new_value_error("Invalid value for timestamp"));
10061007
}
10071008
let secs = float.floor();
1009+
#[cfg_attr(target_env = "musl", allow(deprecated))]
10081010
if secs < libc::time_t::MIN as f64 || secs > libc::time_t::MAX as f64 {
10091011
return Err(vm.new_overflow_error("timestamp out of range for platform time_t"));
10101012
}
1013+
#[cfg_attr(target_env = "musl", allow(deprecated))]
10111014
Ok(secs as libc::time_t)
10121015
}
10131016
Either::B(int) => {
10141017
// try_into is needed on 32-bit platforms where time_t != i64
10151018
#[allow(clippy::useless_conversion)]
1019+
#[cfg_attr(target_env = "musl", allow(deprecated))]
10161020
let ts: libc::time_t = int.try_into().map_err(|_| {
10171021
vm.new_overflow_error("timestamp out of range for platform time_t")
10181022
})?;
@@ -1052,6 +1056,7 @@ mod platform {
10521056
convert::IntoPyException,
10531057
};
10541058
use core::time::Duration;
1059+
#[cfg_attr(target_env = "musl", allow(deprecated))]
10551060
use libc::time_t;
10561061
use nix::{sys::time::TimeSpec, time::ClockId};
10571062

@@ -1116,10 +1121,12 @@ mod platform {
11161121
}
11171122
}
11181123

1124+
#[cfg_attr(target_env = "musl", allow(deprecated))]
11191125
pub(super) fn current_time_t() -> time_t {
11201126
unsafe { libc::time(core::ptr::null_mut()) }
11211127
}
11221128

1129+
#[cfg_attr(target_env = "musl", allow(deprecated))]
11231130
pub(super) fn gmtime_from_timestamp(
11241131
when: time_t,
11251132
vm: &VirtualMachine,
@@ -1132,6 +1139,7 @@ mod platform {
11321139
Ok(struct_time_from_tm(vm, unsafe { out.assume_init() }))
11331140
}
11341141

1142+
#[cfg_attr(target_env = "musl", allow(deprecated))]
11351143
pub(super) fn localtime_from_timestamp(
11361144
when: time_t,
11371145
vm: &VirtualMachine,
@@ -1200,6 +1208,7 @@ mod platform {
12001208

12011209
#[cfg(not(target_os = "redox"))]
12021210
#[cfg(any(not(target_vendor = "apple"), target_os = "macos"))]
1211+
#[cfg_attr(target_env = "musl", allow(deprecated))]
12031212
#[pyfunction]
12041213
fn clock_settime_ns(clk_id: ClockId, time: libc::time_t, vm: &VirtualMachine) -> PyResult<()> {
12051214
let ts = Duration::from_nanos(time as _).into();
@@ -1369,10 +1378,12 @@ mod platform {
13691378
}
13701379
}
13711380

1381+
#[cfg_attr(target_env = "musl", allow(deprecated))]
13721382
pub(super) fn current_time_t() -> libc::time_t {
13731383
unsafe { libc::time(core::ptr::null_mut()) }
13741384
}
13751385

1386+
#[cfg_attr(target_env = "musl", allow(deprecated))]
13761387
pub(super) fn gmtime_from_timestamp(
13771388
when: libc::time_t,
13781389
vm: &VirtualMachine,
@@ -1390,6 +1401,7 @@ mod platform {
13901401
))
13911402
}
13921403

1404+
#[cfg_attr(target_env = "musl", allow(deprecated))]
13931405
pub(super) fn localtime_from_timestamp(
13941406
when: libc::time_t,
13951407
vm: &VirtualMachine,

0 commit comments

Comments
 (0)