Skip to content

Commit 3d1a74d

Browse files
committed
os::ffi_ext -> common::os::ffi
1 parent 877ba28 commit 3d1a74d

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

vm/src/stdlib/os.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ use std::{
1010
path::{Path, PathBuf},
1111
};
1212

13-
#[cfg(unix)]
14-
use std::os::unix::ffi as ffi_ext;
15-
#[cfg(target_os = "wasi")]
16-
use std::os::wasi::ffi as ffi_ext;
17-
1813
#[derive(Debug, Copy, Clone)]
1914
pub(super) enum OutputMode {
2015
String,
@@ -36,7 +31,7 @@ impl OutputMode {
3631
OutputMode::Bytes => {
3732
#[cfg(any(unix, target_os = "wasi"))]
3833
{
39-
use ffi_ext::OsStringExt;
34+
use rustpython_common::os::ffi::OsStringExt;
4035
Ok(vm.ctx.new_bytes(path.into_os_string().into_vec()).into())
4136
}
4237
#[cfg(windows)]
@@ -66,7 +61,7 @@ impl PyPathLike {
6661

6762
#[cfg(any(unix, target_os = "wasi"))]
6863
pub fn into_bytes(self) -> Vec<u8> {
69-
use ffi_ext::OsStringExt;
64+
use rustpython_common::os::ffi::OsStringExt;
7065
self.path.into_os_string().into_vec()
7166
}
7267

@@ -524,7 +519,7 @@ pub(super) mod _os {
524519
}
525520
#[cfg(all(unix, not(target_os = "redox")))]
526521
{
527-
use super::ffi_ext::OsStrExt;
522+
use rustpython_common::os::ffi::OsStrExt;
528523
let new_fd = nix::unistd::dup(fno).map_err(|e| e.into_pyexception(vm))?;
529524
let mut dir =
530525
nix::dir::Dir::from_fd(new_fd).map_err(|e| e.into_pyexception(vm))?;
@@ -1060,7 +1055,7 @@ pub(super) mod _os {
10601055
let mut stat = std::mem::MaybeUninit::uninit();
10611056
let ret = match file {
10621057
PathOrFd::Path(path) => {
1063-
use super::ffi_ext::OsStrExt;
1058+
use rustpython_common::os::ffi::OsStrExt;
10641059
let path = path.as_ref().as_os_str().as_bytes();
10651060
let path = match ffi::CString::new(path) {
10661061
Ok(x) => x,

vm/src/stdlib/posix.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub mod module {
4141
env,
4242
ffi::{CStr, CString},
4343
fs, io,
44-
os::unix::{ffi as ffi_ext, io::RawFd},
44+
os::unix::io::RawFd,
4545
};
4646
use strum_macros::{EnumIter, EnumString};
4747

@@ -285,7 +285,7 @@ pub mod module {
285285

286286
#[pyattr]
287287
fn environ(vm: &VirtualMachine) -> PyDictRef {
288-
use ffi_ext::OsStringExt;
288+
use rustpython_common::os::ffi::OsStringExt;
289289

290290
let environ = vm.ctx.new_dict();
291291
for (key, value) in env::vars_os() {

vm/src/stdlib/posix_compat.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ pub(crate) mod module {
1616
PyObjectRef, PyResult, VirtualMachine,
1717
};
1818
use std::env;
19-
#[cfg(unix)]
20-
use std::os::unix::ffi as ffi_ext;
21-
#[cfg(target_os = "wasi")]
22-
use std::os::wasi::ffi as ffi_ext;
2319

2420
#[pyfunction]
2521
pub(super) fn access(_path: PyStrRef, _mode: u8, vm: &VirtualMachine) -> PyResult<bool> {
@@ -45,7 +41,7 @@ pub(crate) mod module {
4541
#[cfg(target_os = "wasi")]
4642
#[pyattr]
4743
fn environ(vm: &VirtualMachine) -> crate::builtins::PyDictRef {
48-
use ffi_ext::OsStringExt;
44+
use rustpython_common::os::ffi::OsStringExt;
4945

5046
let environ = vm.ctx.new_dict();
5147
for (key, value) in env::vars_os() {

0 commit comments

Comments
 (0)