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

Method _lookup_text_encoding

crates/vm/src/codecs.rs:271–285  ·  view source on GitHub ↗
(
        &self,
        encoding: &str,
        generic_func: &str,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

269 }
270
271 fn _lookup_text_encoding(
272 &self,
273 encoding: &str,
274 generic_func: &str,
275 vm: &VirtualMachine,
276 ) -> PyResult<PyCodec> {
277 let codec = self.lookup(encoding, vm)?;
278 if codec.is_text_codec(vm)? {
279 Ok(codec)
280 } else {
281 Err(vm.new_lookup_error(format!(
282 "'{encoding}' is not a text encoding; use {generic_func} to handle arbitrary codecs"
283 )))
284 }
285 }
286
287 pub fn forget(&self, encoding: &str) -> Option<PyCodec> {
288 let encoding = normalize_encoding_name(encoding);

Callers 2

encode_textMethod · 0.80
decode_textMethod · 0.80

Calls 3

is_text_codecMethod · 0.80
ErrClass · 0.50
lookupMethod · 0.45

Tested by

no test coverage detected