Skip to content

Commit 457d123

Browse files
committed
Validate maxvalue > 0 in SemLock and document winerror __reduce__ divergence
1 parent e0d786e commit 457d123

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

crates/stdlib/src/multiprocessing.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,9 @@ mod _multiprocessing {
340340
if args.kind != RECURSIVE_MUTEX && args.kind != SEMAPHORE {
341341
return Err(vm.new_value_error("unrecognized kind".to_owned()));
342342
}
343+
if args.maxvalue <= 0 {
344+
return Err(vm.new_value_error("maxvalue must be positive".to_owned()));
345+
}
343346
if args.value < 0 || args.value > args.maxvalue {
344347
return Err(vm.new_value_error("invalid value".to_owned()));
345348
}

crates/vm/src/exceptions.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,6 +2077,8 @@ pub(super) mod types {
20772077
args_reduced.push(vm.ctx.none());
20782078
args_reduced.push(filename2);
20792079
} else {
2080+
// Diverges from CPython: include winerror even without
2081+
// filename2 so it survives pickle round-trips.
20802082
#[cfg(windows)]
20812083
if let Some(winerror) = winerror {
20822084
args_reduced.push(winerror);

0 commit comments

Comments
 (0)