Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Superset of all_timezones/common_timezones is hardcoded #91

Open
bdrung opened this issue Nov 14, 2022 · 2 comments
Open

Superset of all_timezones/common_timezones is hardcoded #91

bdrung opened this issue Nov 14, 2022 · 2 comments

Comments

@bdrung
Copy link

bdrung commented Nov 14, 2022

On Debian-based systems (including Ubuntu) pytz is patched to use the tzdata information from the system. That allows updating tzdata without needing to update pytz every time.

The superset of all_timezones and common_timezones is hard-coded in the pytz release (in pytz/__init__.py). When tzdata adds a timezone or renames one (e.g. Ubuntu bug #1995864), pytz needs to be updated.

pytz should evaluate the available timezones on the system to work with future tzdata updates.

Bug-Ubuntu: https://launchpad.net/bugs/207604

@stub42
Copy link
Owner

stub42 commented Dec 18, 2022

pytz already gracefully handles timezones disappearing. There is still a problem when new timezones are introduced, such as recently with Europe/Kyiv.

To address this, pytz would need to replace pytz._all_timezones_unchecked with code that scans all available timezones on the system. Debian and Ubuntu are already patching pytz to correctly point it at the system timezone database. This patch could be extended with the necessary replacement code. This should leave systems using the pytz distributed timezone database unaffected and not needing to pay the runtime costs (some other checks could be turned off, so maybe this cost could be nullified, or maybe even improve speed).

It should also be possible to make a similar change to pytz, where if the timezone database is the standard directory + unpacked files and is not the pytz distributed version, then the scan is done. However, a preferable approach pay be to instead stop distributing the tzdata database with pytz at all, and instead switching to https://pypi.org/project/tzdata/ as part of the process of properly retiring pytz in favor of Python stdlib.

@bdrung
Copy link
Author

bdrung commented Mar 21, 2023

I have implemented that patch for the Debian and Ubuntu package in 2022.7.1-2. My long term goal is get rid of pytz in Debian/Ubuntu and rely on zoneinfo from Python >= 3.9. So we are on the same page here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants