-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Open
Labels
stdlibPython modules in the Lib dirPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
Sometimes available_timezones
includes localtime
. This result is not stable. But localtime
should not be included at all.
>>> import zones
>>> zones = zoneinfo.available_timezones()
>>> 'localtime' in zones
True
Information about the data folder where this function scans:
❯ ll /usr/share/zoneinfo
Permissions Size User Group Date Modified Name
drwxr-xr-x - root root 3 Jul 20:37 Africa
drwxr-xr-x - root root 3 Jul 20:37 America
drwxr-xr-x - root root 3 Jul 20:37 Antarctica
drwxr-xr-x - root root 3 Jul 20:37 Arctic
drwxr-xr-x - root root 3 Jul 20:37 Asia
drwxr-xr-x - root root 3 Jul 20:37 Atlantic
drwxr-xr-x - root root 3 Jul 20:37 Australia
drwxr-xr-x - root root 3 Jul 20:37 Etc
drwxr-xr-x - root root 3 Jul 20:37 Europe
drwxr-xr-x - root root 3 Jul 20:37 Indian
drwxr-xr-x - root root 3 Jul 20:37 Pacific
.rw-r--r-- 116 root root 22 Apr 16:56 Factory
lrwxrwxrwx - root root 22 Apr 16:56 GMT -> Etc/GMT
.rw-r--r-- 4.8k root root 6 Sep 2023 iso3166.tab
.rw-r--r-- 5.1k root root 7 Jan 18:46 leap-seconds.list
.rw-r--r-- 3.3k root root 22 Apr 16:56 leapseconds
lrwxrwxrwx - root root 22 Apr 16:56 localtime -> /etc/localtime
lrwxrwxrwx - root root 22 Apr 16:56 posixrules -> America/New_York
.rw-r--r-- 114k root root 22 Apr 16:56 tzdata.zi
lrwxrwxrwx - root root 22 Apr 16:56 UTC -> Etc/UTC
.rw-r--r-- 19k root root 20 Mar 18:43 zone.tab
.rw-r--r-- 18k root root 20 Mar 18:43 zone1970.tab
.rw-r--r-- 8.1k root root 22 Mar 20:21 zonenow.tab
/etc/localtime again, is a symlink:
❯ ll /etc/localtime
Permissions Size User Group Date Modified Name
lrwxrwxrwx - root root 8 Jan 12:15 /etc/localtime -> /usr/share/zoneinfo/Asia/Ho_Chi_Minh
I think in this block, the file path should be resolved for symlink:
cpython/Lib/zoneinfo/_tzpath.py
Lines 157 to 167 in d22a745
fpath = os.path.join(root, file) | |
key = os.path.relpath(fpath, start=tz_root) | |
if os.sep != "/": # pragma: nocover | |
key = key.replace(os.sep, "/") | |
if not key or key in valid_zones: | |
continue | |
if valid_key(fpath): | |
valid_zones.add(key) |
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Linked PRs
ntindle
Metadata
Metadata
Assignees
Labels
stdlibPython modules in the Lib dirPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
Status
No status