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

Method decode

crates/vm/src/codecs.rs:94–112  ·  view source on GitHub ↗
(
        &self,
        obj: PyObjectRef,
        errors: Option<PyUtf8StrRef>,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

92 }
93
94 pub fn decode(
95 &self,
96 obj: PyObjectRef,
97 errors: Option<PyUtf8StrRef>,
98 vm: &VirtualMachine,
99 ) -> PyResult {
100 let args = match errors {
101 Some(errors) => vec![obj, errors.into_wtf8().into()],
102 None => vec![obj],
103 };
104 let res = self.get_decode_func().call(args, vm)?;
105 let res = res
106 .downcast::<PyTuple>()
107 .ok()
108 .filter(|tuple| tuple.len() == 2)
109 .ok_or_else(|| vm.new_type_error("decoder must return a tuple (object,integer)"))?;
110 // we don't actually care about the integer
111 Ok(res[0].clone())
112 }
113
114 pub fn get_incremental_encoder(
115 &self,

Callers 2

_get_sourceMethod · 0.45
decode_textMethod · 0.45

Calls 8

get_decode_funcMethod · 0.80
ok_or_elseMethod · 0.80
okMethod · 0.80
callMethod · 0.45
filterMethod · 0.45
lenMethod · 0.45
cloneMethod · 0.45
lookupMethod · 0.45

Tested by

no test coverage detected