Skip to content

Difference between _string.formatter_parser in cpython and rustpython #5427

Closed
RustPython/Parser
#124
@kaanyalova

Description

@kaanyalova

The outputs of this script are different between rustpython and cpython

import _string

format_string = "{title[:220]}"


for literal_text, field_name, format_spec, conv in _string.formatter_parser(
    format_string
):
    print(
        f"literal_text: '{literal_text}' field_name: '{field_name}, format_spec: '{format_spec}, conv: {conv}'"
    )

cpython prints correctly:

literal_text: '' field_name: 'title[:220], format_spec: ', conv: None'

while rustpython prints:

literal_text: '' field_name: 'title[, format_spec: '220], conv: None'

this seems to cause issues when using gallery_dl as this is used for formatting file names in some extractors

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions