Skip to content
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
13 changes: 7 additions & 6 deletions crates/stdlib/src/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,13 +485,14 @@ mod decl {
}

#[derive(FromArgs)]
#[allow(dead_code)]
struct EpollExitArgs {
#[pyarg(positional, optional, name = "exc_type", py_default = "None")]
_exc_type: OptionalArg,
#[pyarg(positional, optional, name = "exc_value", py_default = "None")]
_exc_value: OptionalArg,
#[pyarg(positional, optional, name = "exc_tb", py_default = "None")]
_exc_tb: OptionalArg,
#[pyarg(positional, default = None)]
exc_type: Option<PyObjectRef>,
#[pyarg(positional, default = None)]
exc_value: Option<PyObjectRef>,
#[pyarg(positional, default = None)]
exc_tb: Option<PyObjectRef>,
}

#[pyclass(with(Constructor))]
Expand Down
11 changes: 3 additions & 8 deletions crates/vm/src/stdlib/_signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,18 +406,15 @@ pub(crate) mod _signal {
Ok(old_fd as i64)
}

#[cfg(any(target_os = "android", target_os = "linux"))]
use crate::function::OptionalArg;

#[cfg(any(target_os = "android", target_os = "linux"))]
#[derive(FromArgs)]
struct PidfdSendSignalArgs {
#[pyarg(positional)]
pidfd: i32,
#[pyarg(positional, name = "signalnum")]
sig: core::ffi::c_int,
#[pyarg(positional, optional, py_default = "None")]
siginfo: OptionalArg<PyObjectRef>,
#[pyarg(positional, default = None)]
siginfo: Option<PyObjectRef>,
#[pyarg(positional, default)]
flags: core::ffi::c_int,
}
Expand All @@ -433,9 +430,7 @@ pub(crate) mod _signal {
}: PidfdSendSignalArgs,
vm: &VirtualMachine,
) -> PyResult<()> {
if let OptionalArg::Present(obj) = siginfo
&& !vm.is_none(&obj)
{
if siginfo.is_some() {
return Err(vm.new_type_error("siginfo must be None"));
}

Expand Down
8 changes: 4 additions & 4 deletions crates/vm/src/stdlib/_sre.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mod _sre {
common::wtf8::{Wtf8, Wtf8Buf, wtf8_concat},
common::{ascii, hash::PyHash},
convert::ToPyObject,
function::{ArgCallable, DefaultRepr, OptionalArg, PosArgs, PyComparisonValue},
function::{ArgCallable, DefaultRepr, PosArgs, PyComparisonValue},
protocol::{BufferFlags, PyBuffer, PyCallable, PyMappingMethods},
stdlib::sys,
types::{AsMapping, Comparable, Hashable, Representable},
Expand Down Expand Up @@ -338,8 +338,8 @@ mod _sre {
#[derive(FromArgs)]
struct DefaultArg {
// Missing default is None.
#[pyarg(any, optional, py_default = "None")]
default: OptionalArg<PyObjectRef>,
#[pyarg(any, default = None)]
default: Option<PyObjectRef>,
}

/// A position in the searched string, taken as a Py_ssize_t; a negative
Expand Down Expand Up @@ -648,7 +648,7 @@ mod _sre {
} else {
m.groups(
DefaultArg {
default: OptionalArg::Present(empty.clone()),
default: Some(empty.clone()),
},
vm,
)?
Expand Down
8 changes: 4 additions & 4 deletions crates/vm/src/stdlib/posix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1103,8 +1103,8 @@ pub mod module {
path: MkfifoPath,
#[pyarg(any, default = MkfifoMode(0o666), py_default = "438")]
mode: MkfifoMode,
#[pyarg(named, optional, py_default = "None")]
dir_fd: OptionalArg<PyObjectRef>,
#[pyarg(named, default = None)]
dir_fd: Option<PyObjectRef>,
}

#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
Expand All @@ -1115,7 +1115,7 @@ pub mod module {
// Keep a raw C int: even -1 is valid with an absolute path, for which
// mkfifoat ignores dir_fd. BorrowedFd cannot represent that value.
let dir_fd = match args.dir_fd {
OptionalArg::Present(fd) if !vm.is_none(&fd) => {
Some(fd) => {
warn_if_bool_fd(&fd, vm)?;
let fd = fd.try_index_opt(vm).unwrap_or_else(|| {
Err(vm.new_type_error(format!(
Expand All @@ -1133,7 +1133,7 @@ pub mod module {
})?;
(fd != rustpython_host_env::os::AT_FDCWD).then_some(fd)
}
_ => None,
None => None,
};
if dir_fd.is_some() && !host_posix::has_mkfifoat() {
return Err(vm.new_not_implemented_error("dir_fd unavailable on this platform"));
Expand Down
Loading