mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09: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:
@@ -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