MCPcopy Index your code
hub / github.com/RustPython/RustPython / try_from_object

Method try_from_object

crates/vm/src/function/fspath.rs:142–152  ·  view source on GitHub ↗

PyUnicode_FSDecoder in CPython

(vm: &VirtualMachine, obj: PyObjectRef)

Source from the content-addressed store, hash-verified

140impl TryFromObject for FsPath {
141 // PyUnicode_FSDecoder in CPython
142 fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self> {
143 let obj = match obj.try_to_value::<PyBuffer>(vm) {
144 Ok(buffer) => {
145 let mut bytes = vec![];
146 buffer.append_to(&mut bytes);
147 vm.ctx.new_bytes(bytes).into()
148 }
149 Err(_) => obj,
150 };
151 Self::try_from_path_like(obj, true, vm)
152 }
153}

Callers

nothing calls this directly

Calls 2

append_toMethod · 0.45
new_bytesMethod · 0.45

Tested by

no test coverage detected