Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Lib/test/test_str.py
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,6 @@ def test_format_huge_precision(self):
with self.assertRaises(ValueError):
result = format(2.34, format_string)

@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: ValueError not raised
def test_format_huge_width(self):
format_string = "{}f".format(sys.maxsize + 1)
with self.assertRaises(ValueError):
Expand Down
5 changes: 5 additions & 0 deletions crates/common/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ impl FormatSpec {
let (alternate_form, text) = parse_alternate_form(text);
let (zero, text) = parse_zero(text);
let (width, text) = parse_number(text)?;
if let Some(w) = width
&& w > i32::MAX as usize
{
return Err(FormatSpecError::DecimalDigitsTooMany);
}
let (grouping_option, text) = FormatGrouping::parse(text);
if let Some(grouping) = &grouping_option {
Self::validate_separator(grouping, text)?;
Expand Down
Loading