Fix os.py for nt

This commit is contained in:
Jeong YunWon
2021-09-22 21:29:43 +09:00
parent 4cae03b5e0
commit 56fb733b0d
2 changed files with 14 additions and 13 deletions

View File

@@ -362,7 +362,7 @@ fn bytes_as_osstr<'a>(b: &'a [u8], vm: &VirtualMachine) -> PyResult<&'a ffi::OsS
.map_err(|_| vm.new_unicode_decode_error("can't decode path for utf-8".to_owned()))
}
#[pymodule(name = "os")]
#[pymodule(name = "_os")]
pub(super) mod _os {
use super::{
errno_err, DirFd, FollowSymlinks, FsPath, OutputMode, PathOrFd, PyPathLike, SupportFunc,
@@ -403,6 +403,15 @@ pub(super) mod _os {
SEEK_SET,
};
#[pyattr]
pub(crate) const F_OK: u8 = 0;
#[pyattr]
pub(crate) const R_OK: u8 = 1 << 2;
#[pyattr]
pub(crate) const W_OK: u8 = 1 << 1;
#[pyattr]
pub(crate) const X_OK: u8 = 1 << 0;
#[pyfunction]
fn close(fileno: i32, vm: &VirtualMachine) -> PyResult<()> {
Fd(fileno).close().map_err(|e| e.into_pyexception(vm))

View File

@@ -60,14 +60,6 @@ pub mod module {
#[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "linux"))]
#[pyattr]
use libc::{SEEK_DATA, SEEK_HOLE};
#[pyattr]
pub(crate) const F_OK: u8 = 0;
#[pyattr]
pub(crate) const R_OK: u8 = 4;
#[pyattr]
pub(crate) const W_OK: u8 = 2;
#[pyattr]
pub(crate) const X_OK: u8 = 1;
#[cfg(not(any(target_os = "redox", target_os = "freebsd")))]
#[pyattr]
@@ -161,10 +153,10 @@ pub mod module {
// Flags for os_access
bitflags! {
pub struct AccessFlags: u8{
const F_OK = F_OK;
const R_OK = R_OK;
const W_OK = W_OK;
const X_OK = X_OK;
const F_OK = _os::F_OK;
const R_OK = _os::R_OK;
const W_OK = _os::W_OK;
const X_OK = _os::X_OK;
}
}