File tree 2 files changed +8
-10
lines changed 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change 113
113
assert float (1.2 ) == 1.2
114
114
# assert math.trunc(1.2) == 1
115
115
116
+ assert 1.2 ** 2 == 1.44
117
+ assert_raises (OverflowError , lambda : 1.2 ** (10 ** 1000 ))
118
+
116
119
assert (1.7 ).real == 1.7
117
120
assert (1.3 ).is_integer () == False
118
121
assert (1.0 ).is_integer () == True
Original file line number Diff line number Diff line change @@ -262,16 +262,11 @@ impl PyFloat {
262
262
}
263
263
264
264
#[ pymethod( name = "__pow__" ) ]
265
- fn pow ( & self , other : PyObjectRef , vm : & VirtualMachine ) -> PyObjectRef {
266
- let v1 = self . value ;
267
- if objtype:: isinstance ( & other, & vm. ctx . float_type ( ) ) {
268
- vm. ctx . new_float ( v1. powf ( get_value ( & other) ) )
269
- } else if objtype:: isinstance ( & other, & vm. ctx . int_type ( ) ) {
270
- let result = v1. powf ( objint:: get_value ( & other) . to_f64 ( ) . unwrap ( ) ) ;
271
- vm. ctx . new_float ( result)
272
- } else {
273
- vm. ctx . not_implemented ( )
274
- }
265
+ fn pow ( & self , other : PyObjectRef , vm : & VirtualMachine ) -> PyResult {
266
+ try_float ( & other, vm) ?. map_or_else (
267
+ || Ok ( vm. ctx . not_implemented ( ) ) ,
268
+ |other| self . value . powf ( other) . into_pyobject ( vm) ,
269
+ )
275
270
}
276
271
277
272
#[ pymethod( name = "__sub__" ) ]
You can’t perform that action at this time.
0 commit comments