django-timezone-field icon indicating copy to clipboard operation
django-timezone-field copied to clipboard

PYTZ 2022.2 Update Issues

Open K-MTG opened this issue 1 year ago • 6 comments

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'

K-MTG avatar Aug 12 '22 03:08 K-MTG

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.

stub42 avatar Aug 12 '22 09:08 stub42

For anyone running into this issue, as a quick fix, ensure that you have pytz==2022.1 installed instead of pytz==2022.2

macmichael01 avatar Aug 12 '22 16:08 macmichael01

This issue also impacts people who are using tzdata instead of pytz: https://github.com/python/tzdata/issues/53

twschiller avatar Aug 12 '22 20:08 twschiller

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.

jeremystretch avatar Aug 17 '22 16:08 jeremystretch

Having the same issue with pytz==2022.2.1 and tzdata==2022.2 for "Europe/Kyiv"

moshfrid avatar Aug 24 '22 18:08 moshfrid

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.

rarenatoe avatar Sep 03 '22 01:09 rarenatoe