File tree Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change 1
1
use crate :: builtins:: bytes:: PyBytesRef ;
2
- use crate :: builtins:: float:: try_float ;
2
+ use crate :: builtins:: float:: IntoPyFloat ;
3
3
use crate :: builtins:: list:: PyList ;
4
4
use crate :: builtins:: memory:: { Buffer , BufferOptions , ResizeGuard } ;
5
5
use crate :: builtins:: pystr:: PyStrRef ;
@@ -449,14 +449,11 @@ fn f64_swap_bytes(x: f64) -> f64 {
449
449
}
450
450
451
451
fn f32_try_into_from_object ( vm : & VirtualMachine , obj : PyObjectRef ) -> PyResult < f32 > {
452
- try_float ( & obj, vm) ?
453
- . map ( |x| x as f32 )
454
- . ok_or_else ( || vm. new_type_error ( format ! ( "must be real number, not {}" , obj. class( ) . name) ) )
452
+ IntoPyFloat :: try_from_object ( vm, obj) . map ( |x| x. to_f64 ( ) as f32 )
455
453
}
456
454
457
455
fn f64_try_into_from_object ( vm : & VirtualMachine , obj : PyObjectRef ) -> PyResult < f64 > {
458
- try_float ( & obj, vm) ?
459
- . ok_or_else ( || vm. new_type_error ( format ! ( "must be real number, not {}" , obj. class( ) . name) ) )
456
+ IntoPyFloat :: try_from_object ( vm, obj) . map ( |x| x. to_f64 ( ) )
460
457
}
461
458
462
459
#[ pyclass( module = "array" , name = "array" ) ]
You can’t perform that action at this time.
0 commit comments