diff --git a/vm/src/stdlib/os.rs b/vm/src/stdlib/os.rs index a8e209d4f..e3b853710 100644 --- a/vm/src/stdlib/os.rs +++ b/vm/src/stdlib/os.rs @@ -1696,12 +1696,7 @@ mod _os { fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult { match obj.downcast::() { Ok(int) => int::try_to_primitive(int.as_bigint(), vm).map(Self::Val), - Err(obj) => { - let cstring = std::ffi::CString::try_from_object(vm, obj)?; - cstring.into_string().map(Self::Name).map_err(|e| { - vm.new_os_error(format!("error while parsing string: {:?}", e)) - }) - } + Err(obj) => PyStrRef::try_from_object(vm, obj).map(|o| Self::Name(o.to_string())), } } }