mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
Optimize error info
This commit is contained in:
@@ -31,7 +31,12 @@ pub fn boolval(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<bool> {
|
||||
let bool_obj = vm.invoke(method, PyFuncArgs::default())?;
|
||||
match bool_obj.payload::<PyInt>() {
|
||||
Some(int_obj) => !int_obj.as_bigint().is_zero(),
|
||||
None => return Err(vm.new_type_error(String::from(""))),
|
||||
None => {
|
||||
return Err(vm.new_type_error(format!(
|
||||
"__bool__ should return bool, returned type {}",
|
||||
bool_obj.class().name
|
||||
)))
|
||||
}
|
||||
}
|
||||
}
|
||||
None => match vm.get_method(obj.clone(), "__len__") {
|
||||
|
||||
Reference in New Issue
Block a user