diff --git a/vm/src/stdlib/errno.rs b/vm/src/stdlib/errno.rs index 7aa55fcd8..6113b48c2 100644 --- a/vm/src/stdlib/errno.rs +++ b/vm/src/stdlib/errno.rs @@ -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), diff --git a/vm/src/stdlib/os.rs b/vm/src/stdlib/os.rs index 4c59a3c95..ea9f22485 100644 --- a/vm/src/stdlib/os.rs +++ b/vm/src/stdlib/os.rs @@ -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 }