Skip to content

Commit 92d8e2c

Browse files
authored
add os.getcwdb function
1 parent 6e796d7 commit 92d8e2c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Lib/test/test_os.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ def test_getcwd_long_path(self):
141141
if support.verbose:
142142
print(f"Tested current directory length: {len(cwd)}")
143143

144-
# TODO: RUSTPYTHON (AttributeError: module 'os' has no attribute 'getcwdb')
145-
@unittest.expectedFailure
146144
def test_getcwdb(self):
147145
cwd = os.getcwdb()
148146
self.assertIsInstance(cwd, bytes)

vm/src/stdlib/os.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,11 @@ mod _os {
682682
.to_owned())
683683
}
684684

685+
#[pyfunction]
686+
fn getcwdb(vm: &VirtualMachine) -> PyResult<Vec<u8>> {
687+
Ok(getcwd(vm)?.into_bytes().to_vec())
688+
}
689+
685690
#[pyfunction]
686691
fn chdir(path: PyPathLike, vm: &VirtualMachine) -> PyResult<()> {
687692
env::set_current_dir(&path.path).map_err(|err| err.into_pyexception(vm))

0 commit comments

Comments
 (0)