Skip to content

Commit 536ce4d

Browse files
authored
Merge pull request RustPython#4403 from yt2b/fix_exponential_format
Fix exponential format
2 parents d0f6af0 + bd35b00 commit 536ce4d

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

common/src/format.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -513,13 +513,9 @@ impl FormatSpec {
513513
Some(_) | None => Err("%c arg not in range(0x110000)"),
514514
},
515515
},
516-
Some(FormatType::GeneralFormatUpper) => {
517-
Err("Unknown format code 'G' for object of type 'int'")
518-
}
519-
Some(FormatType::GeneralFormatLower) => {
520-
Err("Unknown format code 'g' for object of type 'int'")
521-
}
522-
Some(FormatType::FixedPointUpper)
516+
Some(FormatType::GeneralFormatUpper)
517+
| Some(FormatType::GeneralFormatLower)
518+
| Some(FormatType::FixedPointUpper)
523519
| Some(FormatType::FixedPointLower)
524520
| Some(FormatType::ExponentUpper)
525521
| Some(FormatType::ExponentLower)

extra_tests/snippets/builtin_format.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,5 @@ def test_zero_padding():
6464
assert f"{123.456:010,}" == "00,123.456"
6565
assert f"{123.456:011,}" == "000,123.456"
6666
assert f"{123.456:+011,}" == "+00,123.456"
67+
assert f"{1234:.3g}" == "1.23e+03"
68+
assert f"{1234567:.6G}" == "1.23457E+06"

0 commit comments

Comments
 (0)