Skip to content

Commit

Permalink
Debian is being stupid, so I have to ignore /etc/timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
regebro committed Feb 13, 2025
1 parent 52e5372 commit 7a4ede3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ Changes
5.3 (unreleased)
----------------

- Nothing changed yet.
- Debian is for some reason removing support for /etc/timezone, which is bad,
because that's the only place where the timezone is stated in plain text,
and what's worse, they don't delete it. So we can't trust it now,
so when we have multiple configs, we are forced to just ignore it.


5.2 (2023-10-22)
Expand Down
8 changes: 8 additions & 0 deletions tzlocal/unix.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ def _get_localzone_name(_root="/"):

if len(found_configs) > 0:
log.debug(f"{len(found_configs)} found:\n {found_configs}")
# Debian is for some reason removing support for /etc/timezone, which is bad,
# because that's the only place where the timezone is stated in plain text,
# and what's worse, they don't delete it. So we can't trust it now,
# so when we have multiple configs, we are forced to just ignore it.
if len(found_configs) > 1 and "/etc/timezone" in found_configs:
log.warning("/etc/timezone is deprecated on Debian, and no longer reliable. Ignoring.")
del found_configs["/etc/timezone"]

# We found some explicit config of some sort!
if len(found_configs) > 1:
# Uh-oh, multiple configs. See if they match:
Expand Down

0 comments on commit 7a4ede3

Please sign in to comment.