Skip to content

datetime fold value cleanup on increment #137752

@alteest

Description

@alteest

Bug report

Bug description:

Add one microsecond to datetime with fold=1 and this fold is cleanup and we go to the past instead of go to one microsecond ahead

from datetime import datetime, timedelta
from zoneinfo import ZoneInfo

tz = ZoneInfo('Europe/Paris')
dt1 = datetime(2025, 10, 26, 2, 0, 1, tzinfo=tz)
print(dt1)
dt2 = datetime(2025, 10, 26, 2, 0, 1, fold=1, tzinfo=tz)
print(dt2)
dt3 = dt2 + timedelta(microseconds=1)
print(dt3)

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions