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

Method new_unicode_encode_error_real

crates/vm/src/vm/vm_new.rs:293–321  ·  view source on GitHub ↗
(
        &self,
        encoding: PyStrRef,
        object: PyStrRef,
        start: usize,
        end: usize,
        reason: PyStrRef,
    )

Source from the content-addressed store, hash-verified

291 }
292
293 pub fn new_unicode_encode_error_real(
294 &self,
295 encoding: PyStrRef,
296 object: PyStrRef,
297 start: usize,
298 end: usize,
299 reason: PyStrRef,
300 ) -> PyBaseExceptionRef {
301 let start = self.ctx.new_int(start);
302 let end = self.ctx.new_int(end);
303 let exc = self.new_exception(
304 self.ctx.exceptions.unicode_encode_error.to_owned(),
305 vec![
306 encoding.clone().into(),
307 object.clone().into(),
308 start.clone().into(),
309 end.clone().into(),
310 reason.clone().into(),
311 ],
312 );
313 exc.as_object()
314 .set_attr("encoding", encoding, self)
315 .unwrap();
316 exc.as_object().set_attr("object", object, self).unwrap();
317 exc.as_object().set_attr("start", start, self).unwrap();
318 exc.as_object().set_attr("end", end, self).unwrap();
319 exc.as_object().set_attr("reason", reason, self).unwrap();
320 exc
321 }
322
323 // TODO: don't take ownership should make the success path faster
324 pub fn new_key_error(&self, obj: PyObjectRef) -> PyBaseExceptionRef {

Callers 3

error_encodingMethod · 0.80
encode_code_page_errorsFunction · 0.80
ensure_valid_utf8Method · 0.80

Calls 6

new_exceptionMethod · 0.80
new_intMethod · 0.45
to_ownedMethod · 0.45
unwrapMethod · 0.45
set_attrMethod · 0.45
as_objectMethod · 0.45

Tested by

no test coverage detected