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 11use crate :: builtins:: bytes:: PyBytesRef ;
2- use crate :: builtins:: float:: try_float ;
2+ use crate :: builtins:: float:: IntoPyFloat ;
33use crate :: builtins:: list:: PyList ;
44use crate :: builtins:: memory:: { Buffer , BufferOptions , ResizeGuard } ;
55use crate :: builtins:: pystr:: PyStrRef ;
@@ -449,14 +449,11 @@ fn f64_swap_bytes(x: f64) -> f64 {
449449}
450450
451451fn 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 )
455453}
456454
457455fn 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 ( ) )
460457}
461458
462459#[ pyclass( module = "array" , name = "array" ) ]
You can’t perform that action at this time.
0 commit comments