mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
1 parent
848db340da
commit
3dced01af0
3 files changed
+12
-10
No files matched your search
@@ -502,9 +502,9 @@ with TestWithTempDir() as tmpdir:
|
||||
assert set(collected_files) == set(expected_files)
|
||||
|
||||
# system()
|
||||
if "win" not in sys.platform:
|
||||
assert os.system('ls') == 0
|
||||
assert os.system('{') != 0
|
||||
if os.name in ('posix', 'nt'):
|
||||
assert os.system('echo test') == 0
|
||||
assert os.system('&') != 0
|
||||
|
||||
for arg in [None, 1, 1.0, TabError]:
|
||||
assert_raises(TypeError, os.system, arg)
|
||||
|
||||
@@ -142,6 +142,7 @@ pub(super) mod _os {
|
||||
protocol::PyIterReturn,
|
||||
recursion::ReprGuard,
|
||||
types::{IterNext, Iterable, PyStructSequence, Representable, SelfIter},
|
||||
utils::ToCString,
|
||||
vm::VirtualMachine,
|
||||
AsObject, Py, PyObjectRef, PyPayload, PyRef, PyResult, TryFromObject,
|
||||
};
|
||||
@@ -1028,6 +1029,14 @@ pub(super) mod _os {
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(any(unix, windows))]
|
||||
#[pyfunction]
|
||||
fn system(command: PyStrRef, vm: &VirtualMachine) -> PyResult<i32> {
|
||||
let cstr = command.to_cstring(vm)?;
|
||||
let x = unsafe { libc::system(cstr.as_ptr()) };
|
||||
Ok(x)
|
||||
}
|
||||
|
||||
#[derive(FromArgs)]
|
||||
struct UtimeArgs {
|
||||
path: OsPath,
|
||||
|
||||
@@ -901,13 +901,6 @@ pub mod module {
|
||||
nix::unistd::pipe2(oflags).map_err(|err| err.into_pyexception(vm))
|
||||
}
|
||||
|
||||
#[pyfunction]
|
||||
fn system(command: PyStrRef, vm: &VirtualMachine) -> PyResult<i32> {
|
||||
let cstr = command.to_cstring(vm)?;
|
||||
let x = unsafe { libc::system(cstr.as_ptr()) };
|
||||
Ok(x)
|
||||
}
|
||||
|
||||
fn _chmod(
|
||||
path: OsPath,
|
||||
dir_fd: DirFd<0>,
|
||||
|
||||
Reference in new issue
Block a user