django-timezone-field
django-timezone-field copied to clipboard
PYTZ 2022.2 Update Issues
pytz 2022.2 was just released and it seems to have more timezones that aren't supported:
File ".../lib/python3.10/site-packages/timezone_field/fields.py", line 41, in <listcomp>
default_zoneinfo_tzs = [ZoneInfo(tz) for tz in pytz.common_timezones]
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/zoneinfo/_common.py", line 24, in load_tzdata
raise ZoneInfoNotFoundError(f"No time zone found with key {key}")
zoneinfo._common.ZoneInfoNotFoundError: 'No time zone found with key Asia/Hanoi'
pytz 2022.2 includes a new Asia/Hanoi entry in pytz.common_timezones , but Python's zoneinfo (and backports.zoneinfo) do not have that zone in their zoneinfo database (yet) and raise the exception.
There is no way to guarantee that there will not be drift between pytz and zoneinfo in the future. A working fix would be to simply catch the exception and ignore it when building the list, and then confirm that the list has >0 elements in case the database is missing entirely for some reason.
For anyone running into this issue, as a quick fix, ensure that you have pytz==2022.1
installed instead of pytz==2022.2
This issue also impacts people who are using tzdata instead of pytz: https://github.com/python/tzdata/issues/53
This seems to be resolved now with both of the following installed:
pytz==2022.2.1
tzdata==2022.2
I'd still like to merge #95 to avoid similar issues in the future.
Having the same issue with pytz==2022.2.1 and tzdata==2022.2 for "Europe/Kyiv"
Sorry about the bump, but this is blocking me on upgrading some dependency, I'd appreciate merging #95 too and see if it fixes it.