StanFromIreland · GitHub

Bug report

Bug description:

When using _datetimemodule.c implementation:

>>> from datetime import datetime
... from zoneinfo import ZoneInfo
... datetime(2025, 10, 26, 2, 0, tzinfo=ZoneInfo("Europe/Paris"))
...
datetime.datetime(2025, 10, 26, 2, 0, tzinfo=zoneinfo.ZoneInfo(key='Europe/Paris'))

However, with _pydatetime.py implementation:

>>> from _pydatetime import datetime
... from zoneinfo import ZoneInfo
... datetime(2025, 10, 26, 2, 0, tzinfo=ZoneInfo("Europe/Paris"))
...
Traceback (most recent call last):
  File "<python-input-8>", line 3, in <module>
    datetime(2025, 10, 26, 2, 0, tzinfo=ZoneInfo("Europe/Paris"))
    ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.15/_pydatetime.py", line 1807, in __new__
    _check_tzinfo_arg(tzinfo)
    ~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/usr/local/lib/python3.15/_pydatetime.py", line 610, in _check_tzinfo_arg
    raise TypeError(
    ...<2 lines>...
    )
TypeError: tzinfo argument must be None or of a tzinfo subclass, not 'ZoneInfo'

CPython versions tested on:

CPython main branch, 3.14, 3.13

Operating systems tested on:

No response

Linked PRs

Read the original on github.com ↗