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

Method exception_args_as_string

crates/vm/src/exceptions.rs:301–326  ·  view source on GitHub ↗
(&self, varargs: PyTupleRef, str_single: bool)

Source from the content-addressed store, hash-verified

299 }
300
301 fn exception_args_as_string(&self, varargs: PyTupleRef, str_single: bool) -> Vec<PyStrRef> {
302 let vm = self;
303 match varargs.len() {
304 0 => vec![],
305 1 => {
306 let args0_repr = if str_single {
307 varargs[0]
308 .str(vm)
309 .unwrap_or_else(|_| PyStr::from("<element str() failed>").into_ref(&vm.ctx))
310 } else {
311 varargs[0].repr(vm).unwrap_or_else(|_| {
312 PyStr::from("<element repr() failed>").into_ref(&vm.ctx)
313 })
314 };
315 vec![args0_repr]
316 }
317 _ => varargs
318 .iter()
319 .map(|vararg| {
320 vararg.repr(vm).unwrap_or_else(|_| {
321 PyStr::from("<element repr() failed>").into_ref(&vm.ctx)
322 })
323 })
324 .collect(),
325 }
326 }
327
328 pub fn split_exception(
329 &self,

Callers 3

write_exception_innerMethod · 0.80
__str__Method · 0.80
repr_strMethod · 0.80

Calls 7

collectMethod · 0.80
lenMethod · 0.45
strMethod · 0.45
into_refMethod · 0.45
reprMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected