Skip to content

Commit 6cd8644

Browse files
committed
Use PyStrRef to extract String.
1 parent c14e7b0 commit 6cd8644

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

vm/src/stdlib/os.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,12 +1696,7 @@ mod _os {
16961696
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self> {
16971697
match obj.downcast::<int::PyInt>() {
16981698
Ok(int) => int::try_to_primitive(int.as_bigint(), vm).map(Self::Val),
1699-
Err(obj) => {
1700-
let cstring = std::ffi::CString::try_from_object(vm, obj)?;
1701-
cstring.into_string().map(Self::Name).map_err(|e| {
1702-
vm.new_os_error(format!("error while parsing string: {:?}", e))
1703-
})
1704-
}
1699+
Err(obj) => PyStrRef::try_from_object(vm, obj).map(|o| Self::Name(o.to_string())),
17051700
}
17061701
}
17071702
}

0 commit comments

Comments
 (0)