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

Method __str__

crates/stdlib/src/ssl/error.rs:45–61  ·  view source on GitHub ↗
(exc: &Py<PyBaseException>, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

43 // Returns strerror attribute if available, otherwise str(args)
44 #[pymethod]
45 fn __str__(exc: &Py<PyBaseException>, vm: &VirtualMachine) -> PyResult<PyStrRef> {
46 use crate::vm::AsObject;
47 // Try to get strerror attribute first (OSError compatibility)
48 if let Ok(strerror) = exc.as_object().get_attr("strerror", vm)
49 && !vm.is_none(&strerror)
50 {
51 return strerror.str(vm);
52 }
53
54 // Otherwise return str(args)
55 let args = exc.args();
56 if args.len() == 1 {
57 args.as_slice()[0].str(vm)
58 } else {
59 args.as_object().str(vm)
60 }
61 }
62 }
63
64 #[pyattr]

Callers

nothing calls this directly

Calls 7

get_attrMethod · 0.45
as_objectMethod · 0.45
is_noneMethod · 0.45
strMethod · 0.45
argsMethod · 0.45
lenMethod · 0.45
as_sliceMethod · 0.45

Tested by

no test coverage detected