Skip to content

Commit f10bc82

Browse files
committed
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.
1 parent 801a5ed commit f10bc82

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

crates/vm/src/exceptions.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2084,10 +2084,12 @@ pub(super) mod types {
20842084
}
20852085
result.push(args_reduced.into_pytuple(vm).into());
20862086
} else {
2087-
result.push(vm.new_tuple((errno, msg)).into());
2087+
// filename is None - use original args as-is
2088+
// (may contain winerror at position 3)
2089+
result.push(args.into());
20882090
}
20892091
} else {
2090-
result.push(vm.new_tuple((errno, msg)).into());
2092+
result.push(args.into());
20912093
}
20922094
} else {
20932095
result.push(args.into());

0 commit comments

Comments
 (0)