mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
add os.getcwdb function
This commit is contained in:
1 parent
6e796d7cd8
commit
92d8e2c8da
2 files changed
+5
-2
No files matched your search
@@ -141,8 +141,6 @@ class MiscTests(unittest.TestCase):
|
||||
if support.verbose:
|
||||
print(f"Tested current directory length: {len(cwd)}")
|
||||
|
||||
# TODO: RUSTPYTHON (AttributeError: module 'os' has no attribute 'getcwdb')
|
||||
@unittest.expectedFailure
|
||||
def test_getcwdb(self):
|
||||
cwd = os.getcwdb()
|
||||
self.assertIsInstance(cwd, bytes)
|
||||
|
||||
@@ -682,6 +682,11 @@ mod _os {
|
||||
.to_owned())
|
||||
}
|
||||
|
||||
#[pyfunction]
|
||||
fn getcwdb(vm: &VirtualMachine) -> PyResult<Vec<u8>> {
|
||||
Ok(getcwd(vm)?.into_bytes().to_vec())
|
||||
}
|
||||
|
||||
#[pyfunction]
|
||||
fn chdir(path: PyPathLike, vm: &VirtualMachine) -> PyResult<()> {
|
||||
env::set_current_dir(&path.path).map_err(|err| err.into_pyexception(vm))
|
||||
|
||||
Reference in new issue
Block a user