mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
Fix math.log10 to pass some failed tests
Now math.log10 with less than or equal to zero should raise ValueError with "math domain error" message if `x` fit in f64
This commit is contained in:
1 parent
2bedba0e12
commit
ebd0352cfc
1 file changed
+6
-1
+6
-1
@@ -166,7 +166,12 @@ mod math {
|
||||
|
||||
#[pyfunction]
|
||||
fn log10(x: ArgIntoFloat, vm: &VirtualMachine) -> PyResult<f64> {
|
||||
call_math_func!(log10, x, vm)
|
||||
let x = x.to_f64();
|
||||
if x.is_nan() || x > 0.0_f64 {
|
||||
Ok(x.log10())
|
||||
} else {
|
||||
Err(vm.new_value_error("math domain error".to_owned()))
|
||||
}
|
||||
}
|
||||
|
||||
#[pyfunction]
|
||||
|
||||
Reference in new issue
Block a user