From 6cd8644de841c8fd4b4305e207fb753d5621b8a0 Mon Sep 17 00:00:00 2001 From: jfh Date: Thu, 15 Jul 2021 16:08:55 +0300 Subject: [PATCH] Use PyStrRef to extract String. --- vm/src/stdlib/os.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/vm/src/stdlib/os.rs b/vm/src/stdlib/os.rs index a8e209d4fb..e3b8537107 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())), } } }