From 0fb06d857976747b6ba7be75fa2ceed9bcc7f1d6 Mon Sep 17 00:00:00 2001 From: Kai Knoblich <43905002+knobix@users.noreply.github.com> Date: Tue, 3 Oct 2023 11:42:51 +0200 Subject: [PATCH 1/2] backends/zoneinfo.py: Skip using the "Factory" timezone 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'0' Thus drop the "Factory" timezone from the sets before iterating over them to avoid the aforementioned issue. --- timezone_field/backends/zoneinfo.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/timezone_field/backends/zoneinfo.py b/timezone_field/backends/zoneinfo.py index 4dba3c6..f180ae7 100644 --- a/timezone_field/backends/zoneinfo.py +++ b/timezone_field/backends/zoneinfo.py @@ -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) From c3c5343f2ee75cb6fd7ec8d8855e1dfb2cce86b9 Mon Sep 17 00:00:00 2001 From: Mike Fogel Date: Tue, 3 Oct 2023 19:57:16 -0700 Subject: [PATCH 2/2] Add fix to changelog --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1dda0e8..3911f55 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,7 @@ poetry run pytest #### `main` (unreleased!) - Add support for django 5.0 +- Fix issue with `Factory` timezone on some BSD systems ([#114](https://github.com/mfogel/django-timezone-field/issues/114)) #### 6.0.1 (2023-09-07)