Parse path argument (str or bytes) to string
(
arg: &Either<PyStrRef, ArgBytesLike>,
vm: &VirtualMachine,
)
| 1990 | |
| 1991 | /// Parse path argument (str or bytes) to string |
| 1992 | fn parse_path_arg( |
| 1993 | arg: &Either<PyStrRef, ArgBytesLike>, |
| 1994 | vm: &VirtualMachine, |
| 1995 | ) -> PyResult<String> { |
| 1996 | match arg { |
| 1997 | Either::A(s) => Ok(s.clone().try_into_utf8(vm)?.as_str().to_owned()), |
| 1998 | Either::B(b) => String::from_utf8(b.borrow_buf().to_vec()) |
| 1999 | .map_err(|_| vm.new_value_error("path contains invalid UTF-8")), |
| 2000 | } |
| 2001 | } |
| 2002 | |
| 2003 | /// Parse password argument (str, bytes-like, or callable) |
| 2004 | /// |
nothing calls this directly
no test coverage detected