File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed
Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change 1+ from testutils import assert_raises
2+
13# int to int comparisons
24
35assert 1 == 1
3638assert (1 ).real == 1
3739assert (1 ).imag == 0
3840
41+ assert_raises (OverflowError , lambda : 1 << 10 ** 100000 )
3942
4043assert (1 ).__eq__ (1.0 ) == NotImplemented
4144assert (1 ).__ne__ (1.0 ) == NotImplemented
Original file line number Diff line number Diff line change @@ -246,8 +246,7 @@ fn int_lshift(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
246246 match get_value ( i2) {
247247 ref v if * v < BigInt :: zero ( ) => Err ( vm. new_value_error ( "negative shift count" . to_string ( ) ) ) ,
248248 ref v if * v > BigInt :: from ( usize:: max_value ( ) ) => {
249- // TODO: raise OverflowError
250- panic ! ( "Failed converting {} to rust usize" , get_value( i2) ) ;
249+ Err ( vm. new_overflow_error ( "the number is too large to convert to float" . to_string ( ) ) )
251250 }
252251 _ => panic ! ( "Failed converting {} to rust usize" , get_value( i2) ) ,
253252 }
@@ -276,8 +275,7 @@ fn int_rshift(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
276275 match get_value ( i2) {
277276 ref v if * v < BigInt :: zero ( ) => Err ( vm. new_value_error ( "negative shift count" . to_string ( ) ) ) ,
278277 ref v if * v > BigInt :: from ( usize:: max_value ( ) ) => {
279- // TODO: raise OverflowError
280- panic ! ( "Failed converting {} to rust usize" , get_value( i2) ) ;
278+ Err ( vm. new_overflow_error ( "the number is too large to convert to float" . to_string ( ) ) )
281279 }
282280 _ => panic ! ( "Failed converting {} to rust usize" , get_value( i2) ) ,
283281 }
You can’t perform that action at this time.
0 commit comments