add os.getcwdb function

This commit is contained in:
hyperbora authored and GitHub committed 2020-08-30 14:56:28 +09:00
1 parent 6e796d7cd8
commit 92d8e2c8da
2 files changed
+5 -2

No files matched your search

-2
View File
@@ -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)
+5
View File
@@ -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))