mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Always set OSError.errno; have it be None instead of missing
This commit is contained in:
@@ -169,6 +169,7 @@ const ERROR_CODES: &[(&str, i32)] = &[
|
||||
e!(EINPROGRESS),
|
||||
e!(ENXIO),
|
||||
e!(ECANCELED),
|
||||
e!(EWOULDBLOCK),
|
||||
e!(cfg(not(windows)), EOWNERDEAD),
|
||||
e!(cfg(not(windows)), ENOTRECOVERABLE),
|
||||
e!(cfg(windows), WSAEAFNOSUPPORT),
|
||||
|
||||
@@ -171,10 +171,11 @@ pub fn convert_io_error(vm: &VirtualMachine, err: io::Error) -> PyObjectRef {
|
||||
},
|
||||
};
|
||||
let os_error = vm.new_exception(exc_type, err.to_string());
|
||||
if let Some(errno) = err.raw_os_error() {
|
||||
vm.set_attr(&os_error, "errno", vm.ctx.new_int(errno))
|
||||
.unwrap();
|
||||
}
|
||||
let errno = match err.raw_os_error() {
|
||||
Some(errno) => vm.new_int(errno),
|
||||
None => vm.get_none(),
|
||||
};
|
||||
vm.set_attr(&os_error, "errno", errno).unwrap();
|
||||
os_error
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user