Skip to content
Prev Previous commit
Next Next commit
Fix OSError.__reduce__ to preserve winerror when filename is None
When filename is None, __reduce__ was reconstructing a 2-element
(errno, msg) tuple, dropping the winerror at position 3 in the
original args. Use the original args tuple instead, matching CPython.
  • Loading branch information
youknowone committed Feb 23, 2026
commit 9649be17d99a02fc6313c269119dae803d2a9828
6 changes: 4 additions & 2 deletions crates/vm/src/exceptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2084,10 +2084,12 @@ pub(super) mod types {
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
result.push(args_reduced.into_pytuple(vm).into());
} else {
result.push(vm.new_tuple((errno, msg)).into());
// filename is None - use original args as-is
// (may contain winerror at position 3)
result.push(args.into());
}
} else {
result.push(vm.new_tuple((errno, msg)).into());
result.push(args.into());
}
} else {
result.push(args.into());
Expand Down