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

Method fsdecode

crates/vm/src/vm/mod.rs:2221–2236  ·  view source on GitHub ↗
(&self, s: impl Into<OsString>)

Source from the content-addressed store, hash-verified

2219 }
2220
2221 pub fn fsdecode(&self, s: impl Into<OsString>) -> PyStrRef {
2222 match s.into().into_string() {
2223 Ok(s) => self.ctx.new_str(s),
2224 Err(s) => {
2225 let bytes = self.ctx.new_bytes(s.into_encoded_bytes());
2226 let errors = self.fs_encode_errors().to_owned();
2227 let res = self.state.codec_registry.decode_text(
2228 bytes.into(),
2229 "utf-8",
2230 Some(errors),
2231 self,
2232 );
2233 self.expect_pyresult(res, "fsdecode should be lossless and never fail")
2234 }
2235 }
2236 }
2237
2238 pub fn fsencode<'a>(&self, s: &'a Py<PyStr>) -> PyResult<Cow<'a, OsStr>> {
2239 if cfg!(windows) || s.is_utf8() {

Callers 15

get_importerFunction · 0.80
copy2Function · 0.80
_rmtree_safe_fdFunction · 0.80
_win_path_needs_curdirFunction · 0.80
whichFunction · 0.80
normcaseFunction · 0.80
isreservedFunction · 0.80
expanduserFunction · 0.80
replFunction · 0.80
run_pathFunction · 0.80
guess_file_typeMethod · 0.80
_execute_childMethod · 0.80

Calls 8

into_stringMethod · 0.80
fs_encode_errorsMethod · 0.80
decode_textMethod · 0.80
expect_pyresultMethod · 0.80
SomeClass · 0.50
new_strMethod · 0.45
new_bytesMethod · 0.45
to_ownedMethod · 0.45