Skip to content

Error in Format Specification Mini-Language concerning precision_with_grouping in 3.14 #134449

Description

@jonathanpoelen

Documentation

On this page: https://docs.python.org/3.14/library/string.html#grammar-token-format-spec-format_spec

format_spec:             [options][width_and_precision][type]
options:                 [[fill]align][sign]["z"]["#"]["0"]
fill:                    <any character>
align:                   "<" | ">" | "=" | "^"
sign:                    "+" | "-" | " "
width_and_precision:     [width_with_grouping][precision_with_grouping]
width_with_grouping:     [width][grouping]
precision_with_grouping: "." [precision][grouping]
width:                   digit+
precision:               digit+
grouping:                "," | "_"
type:                    "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g"
                         | "G" | "n" | "o" | "s" | "x" | "X" | "%"

The precision_with_grouping syntaxe is wrong, because it accepts . without precision or grouping. But

>>> f'{1234.1234:.f}'
Traceback (most recent call last):
  File "<python-input-17>", line 1, in <module>
    f'{1234.1234:.f}'
      ^^^^^^^^^^^^^^
ValueError: Format specifier missing precision

(The error does not mention grouping either)

The right syntax should be

precision_with_grouping: "." precision [grouping] | "." grouping

Linked PRs

Activity

  1. picnixz commented on May 23, 2025

    @picnixz
    Member

    cc @skirpichev This is something we did right? I don't remember the issue/PR

  2. added
    type-bugAn unexpected behavior, bug, or error
    3.14bugs and security fixes
    3.15bugs and security fixes
    on May 23, 2025
  3. skirpichev commented on May 23, 2025

    @skirpichev
    Member

    Yes, it's not accurate, see #125304 (review). I forgot that, lets fix this.

    @jonathanpoelen, would you like to propose a pr?

  4. self-assigned this
    on May 23, 2025
  5. jonathanpoelen commented on May 24, 2025

    @jonathanpoelen
    Author

    I'll let you do the pr :)

  6. added a commit that references this issue on May 24, 2025
  7. removed their assignment
    on May 25, 2025
  8. skirpichev commented on May 25, 2025

    @skirpichev
    Member

    PR is ready to review: #134608

  9. added a commit that references this issue on Jun 2, 2025
  10. added a commit that references this issue on Jun 2, 2025
  11. added a commit that references this issue on Jun 2, 2025
  12. skirpichev commented on Jun 24, 2025

    @skirpichev
    Member

    #132205 was created before and was slightly better. Anyway, this is closed.

  13. added a commit that references this issue on Jul 12, 2025
  14. added a commit that references this issue on Aug 4, 2025
  15. added a commit that references this issue on Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixes3.15bugs and security fixesdocsDocumentation in the Doc dirtype-bugAn unexpected behavior, bug, or error

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions