Skip to content

Commit

Permalink
backends/zoneinfo.py: Skip using the "Factory" timezone
Browse files Browse the repository at this point in the history
Referencing the "Factory" timezone can lead to ValueError exceptions on some systems, e.g. FreeBSD, if the system zoneinfo database is used:

ValueError: Invalid STD format in b'<Local time zone must be set--use tzsetup>0'

Thus drop the "Factory" timezone from the sets before iterating over them to avoid the aforementioned issue.
  • Loading branch information
knobix authored Oct 3, 2023
1 parent c1d46ab commit 0fb06d8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions timezone_field/backends/zoneinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ class ZoneInfoBackend(TimeZoneBackend):
utc_tzobj = zoneinfo.ZoneInfo("UTC")
all_tzstrs = zoneinfo.available_timezones()
base_tzstrs = zoneinfo.available_timezones()
# Remove the "Factory" timezone as it can cause ValueError exceptions on
# some systems, e.g. FreeBSD, if the system zoneinfo database is used.
all_tzstrs.discard("Factory")
base_tzstrs.discard("Factory")

def is_tzobj(self, value):
return isinstance(value, zoneinfo.ZoneInfo)
Expand Down

0 comments on commit 0fb06d8

Please sign in to comment.