mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Disallow warnings patches (#7249)
* Apply patches * Remove struct cfg_attr * Auto-format: ruff format --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
6addb91bf3
commit
f99a7f3812
5 files changed
+28
-8
No files matched your search
@@ -296,7 +296,8 @@ impl<D: Decompressor> DecompressState<D> {
|
||||
self.eof
|
||||
}
|
||||
|
||||
pub fn decompressor(&self) -> &D {
|
||||
#[cfg_attr(target_os = "android", allow(dead_code))]
|
||||
pub const fn decompressor(&self) -> &D {
|
||||
&self.decompress
|
||||
}
|
||||
|
||||
|
||||
@@ -1226,12 +1226,15 @@ pub(super) mod _os {
|
||||
pub st_gid: PyIntRef,
|
||||
pub st_size: PyIntRef,
|
||||
// Indices 7-9: integer seconds
|
||||
#[cfg_attr(target_env = "musl", allow(deprecated))]
|
||||
#[pyarg(positional, default)]
|
||||
#[pystruct_sequence(unnamed)]
|
||||
pub st_atime_int: libc::time_t,
|
||||
#[cfg_attr(target_env = "musl", allow(deprecated))]
|
||||
#[pyarg(positional, default)]
|
||||
#[pystruct_sequence(unnamed)]
|
||||
pub st_mtime_int: libc::time_t,
|
||||
#[cfg_attr(target_env = "musl", allow(deprecated))]
|
||||
#[pyarg(positional, default)]
|
||||
#[pystruct_sequence(unnamed)]
|
||||
pub st_ctime_int: libc::time_t,
|
||||
|
||||
@@ -51,7 +51,6 @@ pub mod module {
|
||||
use nix::{
|
||||
errno::Errno,
|
||||
fcntl,
|
||||
sys::signal,
|
||||
unistd::{self, Gid, Pid, Uid},
|
||||
};
|
||||
use rustpython_common::os::ffi::OsStringExt;
|
||||
@@ -1530,6 +1529,8 @@ pub mod module {
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "macos"))]
|
||||
impl PosixSpawnArgs {
|
||||
fn spawn(self, spawnp: bool, vm: &VirtualMachine) -> PyResult<libc::pid_t> {
|
||||
use nix::sys::signal;
|
||||
|
||||
use crate::TryFromBorrowedObject;
|
||||
|
||||
let path = self
|
||||
@@ -2566,11 +2567,8 @@ pub mod module {
|
||||
#[pymodule(sub)]
|
||||
mod posix_sched {
|
||||
use crate::{
|
||||
AsObject, Py, PyObjectRef, PyResult, VirtualMachine,
|
||||
builtins::{PyInt, PyTupleRef},
|
||||
convert::ToPyObject,
|
||||
function::FuncArgs,
|
||||
types::PyStructSequence,
|
||||
AsObject, Py, PyObjectRef, PyResult, VirtualMachine, builtins::PyTupleRef,
|
||||
convert::ToPyObject, function::FuncArgs, types::PyStructSequence,
|
||||
};
|
||||
|
||||
#[derive(FromArgs)]
|
||||
@@ -2629,7 +2627,10 @@ mod posix_sched {
|
||||
|
||||
#[cfg(not(target_env = "musl"))]
|
||||
fn convert_sched_param(obj: &PyObjectRef, vm: &VirtualMachine) -> PyResult<libc::sched_param> {
|
||||
use crate::{builtins::PyTuple, class::StaticType};
|
||||
use crate::{
|
||||
builtins::{PyInt, PyTuple},
|
||||
class::StaticType,
|
||||
};
|
||||
if !obj.fast_isinstance(PySchedParam::static_type()) {
|
||||
return Err(vm.new_type_error("must have a sched_param object".to_owned()));
|
||||
}
|
||||
@@ -2653,6 +2654,7 @@ mod posix_sched {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_env = "musl"))]
|
||||
#[derive(FromArgs)]
|
||||
struct SchedSetschedulerArgs {
|
||||
#[pyarg(positional)]
|
||||
@@ -2692,6 +2694,7 @@ mod posix_sched {
|
||||
))
|
||||
}
|
||||
|
||||
#[cfg(not(target_env = "musl"))]
|
||||
#[derive(FromArgs)]
|
||||
struct SchedSetParamArgs {
|
||||
#[pyarg(positional)]
|
||||
|
||||
@@ -998,6 +998,7 @@ mod decl {
|
||||
}
|
||||
|
||||
#[cfg(any(unix, windows))]
|
||||
#[cfg_attr(target_env = "musl", allow(deprecated))]
|
||||
fn pyobj_to_time_t(value: Either<f64, i64>, vm: &VirtualMachine) -> PyResult<libc::time_t> {
|
||||
match value {
|
||||
Either::A(float) => {
|
||||
@@ -1005,14 +1006,17 @@ mod decl {
|
||||
return Err(vm.new_value_error("Invalid value for timestamp"));
|
||||
}
|
||||
let secs = float.floor();
|
||||
#[cfg_attr(target_env = "musl", allow(deprecated))]
|
||||
if secs < libc::time_t::MIN as f64 || secs > libc::time_t::MAX as f64 {
|
||||
return Err(vm.new_overflow_error("timestamp out of range for platform time_t"));
|
||||
}
|
||||
#[cfg_attr(target_env = "musl", allow(deprecated))]
|
||||
Ok(secs as libc::time_t)
|
||||
}
|
||||
Either::B(int) => {
|
||||
// try_into is needed on 32-bit platforms where time_t != i64
|
||||
#[allow(clippy::useless_conversion)]
|
||||
#[cfg_attr(target_env = "musl", allow(deprecated))]
|
||||
let ts: libc::time_t = int.try_into().map_err(|_| {
|
||||
vm.new_overflow_error("timestamp out of range for platform time_t")
|
||||
})?;
|
||||
@@ -1052,6 +1056,7 @@ mod platform {
|
||||
convert::IntoPyException,
|
||||
};
|
||||
use core::time::Duration;
|
||||
#[cfg_attr(target_env = "musl", allow(deprecated))]
|
||||
use libc::time_t;
|
||||
use nix::{sys::time::TimeSpec, time::ClockId};
|
||||
|
||||
@@ -1116,10 +1121,12 @@ mod platform {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(target_env = "musl", allow(deprecated))]
|
||||
pub(super) fn current_time_t() -> time_t {
|
||||
unsafe { libc::time(core::ptr::null_mut()) }
|
||||
}
|
||||
|
||||
#[cfg_attr(target_env = "musl", allow(deprecated))]
|
||||
pub(super) fn gmtime_from_timestamp(
|
||||
when: time_t,
|
||||
vm: &VirtualMachine,
|
||||
@@ -1132,6 +1139,7 @@ mod platform {
|
||||
Ok(struct_time_from_tm(vm, unsafe { out.assume_init() }))
|
||||
}
|
||||
|
||||
#[cfg_attr(target_env = "musl", allow(deprecated))]
|
||||
pub(super) fn localtime_from_timestamp(
|
||||
when: time_t,
|
||||
vm: &VirtualMachine,
|
||||
@@ -1200,6 +1208,7 @@ mod platform {
|
||||
|
||||
#[cfg(not(target_os = "redox"))]
|
||||
#[cfg(any(not(target_vendor = "apple"), target_os = "macos"))]
|
||||
#[cfg_attr(target_env = "musl", allow(deprecated))]
|
||||
#[pyfunction]
|
||||
fn clock_settime_ns(clk_id: ClockId, time: libc::time_t, vm: &VirtualMachine) -> PyResult<()> {
|
||||
let ts = Duration::from_nanos(time as _).into();
|
||||
@@ -1369,10 +1378,12 @@ mod platform {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(target_env = "musl", allow(deprecated))]
|
||||
pub(super) fn current_time_t() -> libc::time_t {
|
||||
unsafe { libc::time(core::ptr::null_mut()) }
|
||||
}
|
||||
|
||||
#[cfg_attr(target_env = "musl", allow(deprecated))]
|
||||
pub(super) fn gmtime_from_timestamp(
|
||||
when: libc::time_t,
|
||||
vm: &VirtualMachine,
|
||||
@@ -1390,6 +1401,7 @@ mod platform {
|
||||
))
|
||||
}
|
||||
|
||||
#[cfg_attr(target_env = "musl", allow(deprecated))]
|
||||
pub(super) fn localtime_from_timestamp(
|
||||
when: libc::time_t,
|
||||
vm: &VirtualMachine,
|
||||
|
||||
@@ -41,6 +41,7 @@ with FileIO("README.md") as fio:
|
||||
nres = fio.read(2)
|
||||
assert len(nres) == 2
|
||||
|
||||
|
||||
# Test that IOBase.isatty() raises ValueError when called on a closed file.
|
||||
# Minimal subclass that inherits IOBase.isatty() without overriding it.
|
||||
class MinimalRaw(RawIOBase):
|
||||
|
||||
Reference in new issue
Block a user