diff --git a/common/src/format.rs b/common/src/format.rs index c8849895d..f9cf05e95 100644 --- a/common/src/format.rs +++ b/common/src/format.rs @@ -513,13 +513,9 @@ impl FormatSpec { Some(_) | None => Err("%c arg not in range(0x110000)"), }, }, - Some(FormatType::GeneralFormatUpper) => { - Err("Unknown format code 'G' for object of type 'int'") - } - Some(FormatType::GeneralFormatLower) => { - Err("Unknown format code 'g' for object of type 'int'") - } - Some(FormatType::FixedPointUpper) + Some(FormatType::GeneralFormatUpper) + | Some(FormatType::GeneralFormatLower) + | Some(FormatType::FixedPointUpper) | Some(FormatType::FixedPointLower) | Some(FormatType::ExponentUpper) | Some(FormatType::ExponentLower) diff --git a/extra_tests/snippets/builtin_format.py b/extra_tests/snippets/builtin_format.py index 838c917a5..fcf395051 100644 --- a/extra_tests/snippets/builtin_format.py +++ b/extra_tests/snippets/builtin_format.py @@ -64,3 +64,5 @@ assert f"{123.456:09,}" == "0,123.456" assert f"{123.456:010,}" == "00,123.456" assert f"{123.456:011,}" == "000,123.456" assert f"{123.456:+011,}" == "+00,123.456" +assert f"{1234:.3g}" == "1.23e+03" +assert f"{1234567:.6G}" == "1.23457E+06"