Skip to content

Commit ff1049a

Browse files
committed
fix regression in the exception representation in the traceback
1 parent cd1d7b1 commit ff1049a

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

vm/src/exceptions.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,18 @@ pub fn print_exception_inner(vm: &VirtualMachine, exc: &PyObjectRef) {
110110
println!("No traceback set on exception");
111111
}
112112

113-
match vm.to_str(exc) {
114-
Ok(txt) => println!("{}", txt.value),
115-
Err(err) => println!("Error during error {:?}", err),
113+
let varargs = vm
114+
.get_attribute(exc.clone(), "args")
115+
.unwrap()
116+
.downcast::<PyTuple>()
117+
.expect("'args' must be a tuple");
118+
let args_repr = exception_args_as_string(vm, varargs);
119+
120+
let exc_repr = exc.class().name.clone();
121+
match args_repr.len() {
122+
0 => println!("{}", exc_repr),
123+
1 => println!("{}: {}", exc_repr, args_repr[0]),
124+
_ => println!("{}: ({})", exc_repr, args_repr.join(", ")),
116125
}
117126
}
118127

0 commit comments

Comments
 (0)