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

Method error_encoding

crates/vm/src/codecs.rs:652–683  ·  view source on GitHub ↗
(&self, range: Range<StrSize>, reason: Option<&str>)

Source from the content-addressed store, hash-verified

650 }
651
652 fn error_encoding(&self, range: Range<StrSize>, reason: Option<&str>) -> Self::Error {
653 let vm = self.vm;
654 match self.exception.get() {
655 Some(exc) => {
656 match update_unicode_error_attrs(
657 exc.as_object(),
658 range.start.chars,
659 range.end.chars,
660 reason,
661 vm,
662 ) {
663 Ok(()) => exc.clone(),
664 Err(e) => e,
665 }
666 }
667 None => self
668 .exception
669 .get_or_init(|| {
670 let reason = reason.expect(
671 "should only ever pass reason: None if an exception is already set",
672 );
673 vm.new_unicode_encode_error_real(
674 vm.ctx.new_str(self.encoding),
675 self.data.to_owned(),
676 range.start.chars,
677 range.end.chars,
678 vm.ctx.new_str(reason),
679 )
680 })
681 .clone(),
682 }
683 }
684}
685
686pub struct PyDecodeContext<'a> {

Callers 4

encode_utf8_compatibleFunction · 0.80
handle_encode_errorMethod · 0.80
encodeFunction · 0.80
handle_encode_errorMethod · 0.80

Calls 8

getMethod · 0.45
as_objectMethod · 0.45
cloneMethod · 0.45
get_or_initMethod · 0.45
new_strMethod · 0.45
to_ownedMethod · 0.45

Tested by

no test coverage detected