Merge pull request #3036 from youknowone/os-comment

implementation comments for os utility
This commit is contained in:
Jeong YunWon
2021-09-11 17:41:12 +09:00
committed by GitHub

View File

@@ -168,6 +168,7 @@ pub(crate) fn fspath(
check_for_nul: bool,
vm: &VirtualMachine,
) -> PyResult<FsPath> {
// PyOS_FSPath in CPython
let check_nul = |b: &[u8]| {
if !check_for_nul || memchr::memchr(b'\0', b).is_none() {
Ok(())
@@ -211,6 +212,7 @@ pub(crate) fn fspath(
impl TryFromObject for PyPathLike {
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self> {
// path_converter in CPython
let obj = match PyBufferRef::try_from_borrowed_object(vm, &obj) {
Ok(buffer) => PyBytes::from(Vec::from(&*buffer.obj_bytes())).into_pyobject(vm),
Err(_) => obj,