Skip to content

Commit 0143f10

Browse files
committed
Fix pendulum.tz.timezones() to use system tzdata
Fix the `pendulum.tz.available_timezones()` to use `available_timezones()` function instead of iterating over the files in `tzdata` package. This is more in line with PEP 615, as the system timezone functions will operate on system-provided tzdata when available, and use the `tzdata` package only if it's not available. Therefore, the previous code would yield a potentially different list of timezones than the system actually provides. Furthermore, Gentoo provides a dummy `tzdata` package that does not provide any data, since Python always uses system tzdata. This change is necessary to make pendulum work again on Gentoo. Fixes #769
1 parent 3e3fec6 commit 0143f10

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/pendulum/tz/__init__.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from pendulum.tz.timezone import UTC
1010
from pendulum.tz.timezone import FixedTimezone
1111
from pendulum.tz.timezone import Timezone
12-
from pendulum.utils._compat import resources
12+
from pendulum.utils._zoneinfo import available_timezones
1313

1414

1515
PRE_TRANSITION = "pre"
@@ -22,13 +22,7 @@
2222

2323

2424
def timezones() -> tuple[str, ...]:
25-
global _timezones
26-
27-
if _timezones is None:
28-
with cast(Path, resources.files("tzdata").joinpath("zones")).open() as f:
29-
_timezones = tuple(tz.strip() for tz in f.readlines())
30-
31-
return _timezones
25+
return available_timezones()
3226

3327

3428
def fixed_timezone(offset: int) -> FixedTimezone:

0 commit comments

Comments
 (0)