Skip to content

print a datetime with f-string #155084

Description

@Pedro-8888

Bug report

Bug description:

This happens when a datetime is printed with an alignment field specified.
The alignment field itself gets printed after the datetime.

import sys
import datetime

print(f'Python version {sys.version}')
print(f'{sys.version_info}')
dt = datetime.date(2026, 1, 1)
print('dt =', dt)
print(f'Date {dt}      prints correctly')
print(f'Date {dt}:<33  wrong the alignment field itself gets printed')
print(f'{'^^^':>19}  ')

CPython versions tested on:

3.14

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions