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
+
1
3
# int to int comparisons
2
4
3
5
assert 1 == 1
36
38
assert (1 ).real == 1
37
39
assert (1 ).imag == 0
38
40
41
+ assert_raises (OverflowError , lambda : 1 << 10 ** 100000 )
39
42
40
43
assert (1 ).__eq__ (1.0 ) == NotImplemented
41
44
assert (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 {
246
246
match get_value ( i2) {
247
247
ref v if * v < BigInt :: zero ( ) => Err ( vm. new_value_error ( "negative shift count" . to_string ( ) ) ) ,
248
248
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 ( ) ) )
251
250
}
252
251
_ => panic ! ( "Failed converting {} to rust usize" , get_value( i2) ) ,
253
252
}
@@ -276,8 +275,7 @@ fn int_rshift(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
276
275
match get_value ( i2) {
277
276
ref v if * v < BigInt :: zero ( ) => Err ( vm. new_value_error ( "negative shift count" . to_string ( ) ) ) ,
278
277
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 ( ) ) )
281
279
}
282
280
_ => panic ! ( "Failed converting {} to rust usize" , get_value( i2) ) ,
283
281
}
You can’t perform that action at this time.
0 commit comments