Skip to content

Commit da02029

Browse files
committed
Refactor boolval()
1 parent 21821b7 commit da02029

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

vm/src/obj/objbool.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,7 @@ pub fn boolval(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<bool> {
3737
)));
3838
}
3939

40-
match bool_obj.payload::<PyInt>() {
41-
Some(int_obj) => !int_obj.as_bigint().is_zero(),
42-
None => {
43-
return Err(vm.new_type_error(format!(
44-
"__bool__ should return bool, returned type {}",
45-
bool_obj.class().name
46-
)))
47-
}
48-
}
40+
get_value(&bool_obj)
4941
}
5042
None => match vm.get_method(obj.clone(), "__len__") {
5143
Some(method_or_err) => {

0 commit comments

Comments
 (0)