mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Merge pull request #5788 from coolreader18/fix-prec
Fix panic with high precision
This commit is contained in:
@@ -55,6 +55,7 @@ pub fn format_fixed(precision: usize, magnitude: f64, case: Case, alternate_form
|
||||
match magnitude {
|
||||
magnitude if magnitude.is_finite() => {
|
||||
let point = decimal_point_or_empty(precision, alternate_form);
|
||||
let precision = std::cmp::min(precision, u16::MAX as usize);
|
||||
format!("{magnitude:.precision$}{point}")
|
||||
}
|
||||
magnitude if magnitude.is_nan() => format_nan(case),
|
||||
|
||||
@@ -259,6 +259,9 @@ mod _io {
|
||||
}
|
||||
|
||||
fn write(&mut self, data: &[u8]) -> Option<u64> {
|
||||
if data.is_empty() {
|
||||
return Some(0);
|
||||
}
|
||||
let length = data.len();
|
||||
self.cursor.write_all(data).ok()?;
|
||||
Some(length as u64)
|
||||
|
||||
Reference in New Issue
Block a user