mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-17 01:51:39 +09:00
add overflow errors for int shifts.
This commit is contained in:
@@ -246,8 +246,7 @@ fn int_lshift(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
match get_value(i2) {
|
||||
ref v if *v < BigInt::zero() => Err(vm.new_value_error("negative shift count".to_string())),
|
||||
ref v if *v > BigInt::from(usize::max_value()) => {
|
||||
// TODO: raise OverflowError
|
||||
panic!("Failed converting {} to rust usize", get_value(i2));
|
||||
Err(vm.new_overflow_error("the number is too large to convert to float".to_string()))
|
||||
}
|
||||
_ => panic!("Failed converting {} to rust usize", get_value(i2)),
|
||||
}
|
||||
@@ -276,8 +275,7 @@ fn int_rshift(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
match get_value(i2) {
|
||||
ref v if *v < BigInt::zero() => Err(vm.new_value_error("negative shift count".to_string())),
|
||||
ref v if *v > BigInt::from(usize::max_value()) => {
|
||||
// TODO: raise OverflowError
|
||||
panic!("Failed converting {} to rust usize", get_value(i2));
|
||||
Err(vm.new_overflow_error("the number is too large to convert to float".to_string()))
|
||||
}
|
||||
_ => panic!("Failed converting {} to rust usize", get_value(i2)),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user