(&self, vm: &VirtualMachine)
| 105 | } |
| 106 | |
| 107 | pub fn to_path_buf(&self, vm: &VirtualMachine) -> PyResult<PathBuf> { |
| 108 | let path = match self { |
| 109 | Self::Str(s) => PathBuf::from(vm.fsencode(s)?.as_ref() as &OsStr), |
| 110 | Self::Bytes(b) => PathBuf::from(Self::bytes_as_os_str(b, vm)?), |
| 111 | }; |
| 112 | Ok(path) |
| 113 | } |
| 114 | |
| 115 | pub fn to_cstring(&self, vm: &VirtualMachine) -> PyResult<alloc::ffi::CString> { |
| 116 | alloc::ffi::CString::new(self.as_bytes()).map_err(|e| e.into_pyexception(vm)) |
no test coverage detected