Skip to content

RFE: use zoneinfo instead of pytz #240

Open

Description

@kloczek

Switch to standard zoneinfo module.
Below may help pydantic/pydantic-core@fd262933

[tkloczko@pers-jacek flask-babel-4.0.0]$ grep -r pytz
README.md:[babel][] and [pytz][] modules.
README.md:[pytz]: https://pypi.python.org/pypi/pytz/
docs/index.rst:any Flask application with the help of `babel`_, `pytz`_ and its own copy of
docs/index.rst:.. _pytz: https://pythonhosted.org/pytz/
flask_babel/__init__.py:from pytz import timezone, UTC
flask_babel/__init__.py:        `pytz.timezone` object.
flask_babel/__init__.py:    a `pytz.timezone` object.  This returns `None` if used outside a request.
pyproject.toml:pytz = ">=2022.7"

Activity

  1. TkTech commented on Jun 19, 2024

    @TkTech
    Contributor

    zoneinfo is only available in Python 3.9+ and we currently support versions before that. When 3.8 hits EOL in 2024-10, we'll switch.

  2. kloczek commented on Jun 19, 2024

    @kloczek
    Author

    All what you wrote is 100% accurate.
    In dropped in RFE commit you have example how to handle that.

  3. andreymal commented on Jun 19, 2024

    @andreymal

    There is backports.zoneinfo (and Django 4.2 uses it, for example)

  4. olejorgenb commented on Jun 18, 2025

    @olejorgenb

    Is this related to this error I'm seeing:

    def to_user_timezone(...):
        ...
        timezone (as returned by :func:`get_timezone`) this function can be used.
        """
        if datetime.tzinfo is None:
            datetime = datetime.replace(tzinfo=UTC)
        tzinfo = get_timezone()
        return tzinfo.normalize(datetime.astimezone(tzinfo))

    'zoneinfo.ZoneInfo' object has no attribute 'normalize'

  5. olejorgenb commented on Jul 22, 2025

    @olejorgenb

    zoneinfo is only available in Python 3.9+ and we currently support versions before that. When 3.8 hits EOL in 2024-10, we'll switch.

    Would a PR be welcome?

  6. homeworkprod commented on Aug 5, 2025

    @homeworkprod
    Contributor

    When 3.8 hits EOL in 2024-10, we'll switch.

    We're past that date. PR to remove Python 3.8 is at #245.

    Python 3.9 will be EOL as well in less than three months.

  7. ElLorans commented on Mar 2, 2026

    @ElLorans

    Would a PR be welcome?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions