Skip to content

string.Formatter class not allowing {.field} #88662

Closed

Description

@avdwoude
mannequin
BPO 44496
Nosy @ericvsmith, @corona10

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2021-06-23.07:26:04.217>
labels = ['3.8', 'type-bug', 'library']
title = 'string.Formatter class not allowing {.field}'
updated_at = <Date 2021-11-03.13:39:08.555>
user = 'https://bugs.python.org/avdwoude'

bugs.python.org fields:

activity = <Date 2021-11-03.13:39:08.555>
actor = 'eric.smith'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2021-06-23.07:26:04.217>
creator = 'avdwoude'
dependencies = []
files = []
hgrepos = []
issue_num = 44496
keywords = []
message_count = 2.0
messages = ['396383', '405615']
nosy_count = 3.0
nosy_names = ['eric.smith', 'corona10', 'avdwoude']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue44496'
versions = ['Python 3.8']

Activity

  1. avdwoude commented on Jun 23, 2021

    avdwoudemannequin
    MannequinAuthor

    I expected the custom Formatter to behave the same as the normal "".format() function, but unnamed args or not supported.
    Below is an example, which fails at a KeyError.

    from string import Formatter
    
    class test():
        def __init__(self):
            self.msg = "OK"
    t = test()

    print("Normal format() is {.msg}".format(t))

    f = Formatter()
    print(f.format("Formatter.format() is {.msg}", t))
  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    type-bugAn unexpected behavior, bug, or error
    on Jun 23, 2021
  3. ericvsmith commented on Nov 3, 2021

    @ericvsmith
    Member

    I think this is a dupe of bpo-27307.

  4. transferred this issue fromon Apr 10, 2022
  5. encukou commented on Jan 31, 2025

    @encukou
    Member

    Fixed by: #21767

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.8 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions