Skip to content

Commit 7b08953

Browse files
committed
rename PyPathLike -> OsPath becasue it is not a python object
1 parent 3d1a74d commit 7b08953

File tree

6 files changed

+97
-96
lines changed

6 files changed

+97
-96
lines changed

stdlib/src/posixsubprocess.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::vm::{
22
builtins::PyListRef,
33
function::ArgSequence,
4-
stdlib::{os::PyPathLike, posix},
4+
stdlib::{os::OsPath, posix},
55
{PyObjectRef, PyResult, TryFromObject, VirtualMachine},
66
};
77
use nix::{errno::Errno, unistd};
@@ -60,7 +60,7 @@ struct CStrPathLike {
6060
}
6161
impl TryFromObject for CStrPathLike {
6262
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self> {
63-
let s = PyPathLike::try_from_object(vm, obj)?.into_cstring(vm)?;
63+
let s = OsPath::try_from_object(vm, obj)?.into_cstring(vm)?;
6464
Ok(CStrPathLike { s })
6565
}
6666
}

vm/src/stdlib/io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3541,7 +3541,7 @@ mod _io {
35413541

35423542
// check file descriptor validity
35433543
#[cfg(unix)]
3544-
if let Ok(crate::stdlib::os::PathOrFd::Fd(fd)) = file.clone().try_into_value(vm) {
3544+
if let Ok(crate::stdlib::os::OsPathOrFd::Fd(fd)) = file.clone().try_into_value(vm) {
35453545
nix::fcntl::fcntl(fd, nix::fcntl::F_GETFD)
35463546
.map_err(|_| crate::stdlib::os::errno_err(vm))?;
35473547
}

vm/src/stdlib/nt.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub(crate) mod module {
1717
function::Either,
1818
function::OptionalArg,
1919
stdlib::os::{
20-
errno_err, DirFd, FollowSymlinks, PyPathLike, SupportFunc, TargetIsDirectory, _os,
20+
errno_err, DirFd, FollowSymlinks, OsPath, SupportFunc, TargetIsDirectory, _os,
2121
},
2222
PyResult, TryFromObject, VirtualMachine,
2323
};
@@ -35,7 +35,7 @@ pub(crate) mod module {
3535
use libc::{O_BINARY, O_TEMPORARY};
3636

3737
#[pyfunction]
38-
pub(super) fn access(path: PyPathLike, mode: u8, vm: &VirtualMachine) -> PyResult<bool> {
38+
pub(super) fn access(path: OsPath, mode: u8, vm: &VirtualMachine) -> PyResult<bool> {
3939
use um::{fileapi, winnt};
4040
let attr = unsafe { fileapi::GetFileAttributesW(path.to_widecstring(vm)?.as_ptr()) };
4141
Ok(attr != fileapi::INVALID_FILE_ATTRIBUTES
@@ -46,8 +46,8 @@ pub(crate) mod module {
4646

4747
#[derive(FromArgs)]
4848
pub(super) struct SymlinkArgs {
49-
src: PyPathLike,
50-
dst: PyPathLike,
49+
src: OsPath,
50+
dst: OsPath,
5151
#[pyarg(flatten)]
5252
target_is_directory: TargetIsDirectory,
5353
#[pyarg(flatten)]
@@ -90,7 +90,7 @@ pub(crate) mod module {
9090

9191
#[pyfunction]
9292
fn chmod(
93-
path: PyPathLike,
93+
path: OsPath,
9494
dir_fd: DirFd<0>,
9595
mode: u32,
9696
follow_symlinks: FollowSymlinks,
@@ -239,7 +239,7 @@ pub(crate) mod module {
239239
}
240240

241241
#[pyfunction]
242-
fn _getfinalpathname(path: PyPathLike, vm: &VirtualMachine) -> PyResult {
242+
fn _getfinalpathname(path: OsPath, vm: &VirtualMachine) -> PyResult {
243243
let real = path
244244
.as_ref()
245245
.canonicalize()
@@ -248,7 +248,7 @@ pub(crate) mod module {
248248
}
249249

250250
#[pyfunction]
251-
fn _getfullpathname(path: PyPathLike, vm: &VirtualMachine) -> PyResult {
251+
fn _getfullpathname(path: OsPath, vm: &VirtualMachine) -> PyResult {
252252
let wpath = path.to_widecstring(vm)?;
253253
let mut buffer = vec![0u16; winapi::shared::minwindef::MAX_PATH];
254254
let ret = unsafe {
@@ -281,7 +281,7 @@ pub(crate) mod module {
281281
}
282282

283283
#[pyfunction]
284-
fn _getvolumepathname(path: PyPathLike, vm: &VirtualMachine) -> PyResult {
284+
fn _getvolumepathname(path: OsPath, vm: &VirtualMachine) -> PyResult {
285285
let wide = path.to_widecstring(vm)?;
286286
let buflen = std::cmp::max(wide.len(), winapi::shared::minwindef::MAX_PATH);
287287
let mut buffer = vec![0u16; buflen];
@@ -296,7 +296,7 @@ pub(crate) mod module {
296296
}
297297

298298
#[pyfunction]
299-
fn _path_splitroot(path: PyPathLike, vm: &VirtualMachine) -> PyResult<(String, String)> {
299+
fn _path_splitroot(path: OsPath, vm: &VirtualMachine) -> PyResult<(String, String)> {
300300
let orig: Vec<_> = path.path.into_os_string().encode_wide().collect();
301301
if orig.is_empty() {
302302
return Ok(("".to_owned(), "".to_owned()));
@@ -334,7 +334,7 @@ pub(crate) mod module {
334334
}
335335

336336
#[pyfunction]
337-
fn _getdiskusage(path: PyPathLike, vm: &VirtualMachine) -> PyResult<(u64, u64)> {
337+
fn _getdiskusage(path: OsPath, vm: &VirtualMachine) -> PyResult<(u64, u64)> {
338338
use um::fileapi::GetDiskFreeSpaceExW;
339339
use winapi::shared::{ntdef::ULARGE_INTEGER, winerror};
340340

@@ -399,7 +399,7 @@ pub(crate) mod module {
399399

400400
#[pyfunction]
401401
fn mkdir(
402-
path: PyPathLike,
402+
path: OsPath,
403403
mode: OptionalArg<i32>,
404404
dir_fd: DirFd<{ _os::MKDIR_DIR_FD as usize }>,
405405
vm: &VirtualMachine,

0 commit comments

Comments
 (0)