Skip to content

Commit ab98775

Browse files
committed
Optimize error info
1 parent 3775e04 commit ab98775

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

vm/src/obj/objbool.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ pub fn boolval(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<bool> {
3131
let bool_obj = vm.invoke(method, PyFuncArgs::default())?;
3232
match bool_obj.payload::<PyInt>() {
3333
Some(int_obj) => !int_obj.as_bigint().is_zero(),
34-
None => return Err(vm.new_type_error(String::from(""))),
34+
None => {
35+
return Err(vm.new_type_error(format!(
36+
"__bool__ should return bool, returned type {}",
37+
bool_obj.class().name
38+
)))
39+
}
3540
}
3641
}
3742
None => match vm.get_method(obj.clone(), "__len__") {

0 commit comments

Comments
 (0)