Skip to content

string.Formatter does not handle non-indexed item and attribute access #129273

@dg-pb

Description

@dg-pb

Bug report

Bug description:

from argparse import Namespace
fmt = '{[0]} {.a}'
fmt.format([10], Namespace(a=1))    # '10 1'

# ---

import string
string.Formatter().format(fmt, [10], Namespace(a=1))
# KeyError: ''

CPython versions tested on:

3.14

Operating systems tested on:

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions