mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Changed PyResult to PyResult<bool>
This commit is contained in:
@@ -221,23 +221,23 @@ fn convert_nix_errno(vm: &VirtualMachine, errno: Errno) -> PyClassRef {
|
||||
}
|
||||
}
|
||||
|
||||
fn os_access(path: PyStringRef, mode: PyIntRef, vm: &VirtualMachine) -> PyResult {
|
||||
fn os_access(path: PyStringRef, mode: PyIntRef, vm: &VirtualMachine) -> PyResult<bool> {
|
||||
let mode = mode.as_bigint().to_u8().unwrap();
|
||||
let path = path.as_str();
|
||||
let file_metadata = fs::metadata(path);
|
||||
match mode {
|
||||
0 => match file_metadata {
|
||||
Ok(_) => Ok(vm.new_bool(true)),
|
||||
Ok(_) => Ok(true),
|
||||
Err(err) => {
|
||||
if err.kind() == ErrorKind::NotFound {
|
||||
Ok(vm.new_bool(false))
|
||||
Ok(false)
|
||||
} else {
|
||||
Err(convert_io_error(vm, err))
|
||||
}
|
||||
}
|
||||
},
|
||||
4 => match file_metadata {
|
||||
Ok(metadata) => Ok(vm.new_bool(metadata.permissions().readonly())),
|
||||
Ok(metadata) => Ok(metadata.permissions().readonly()),
|
||||
Err(err) => Err(convert_io_error(vm, err)),
|
||||
},
|
||||
2 => unimplemented!(),
|
||||
|
||||
Reference in New Issue
Block a user