gh-137976: Explicitly exclude localtime from available_timezones (#138012)

* fix: available_timezones is reporting an invalid IANA zone name

* 📜🤖 Added by blurb_it.

* correct rst format for backticks

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
This commit is contained in:
Nicholas Tindle 2025-09-18 11:32:14 -05:00 committed by GitHub
parent d641c41c88
commit 0f27e10204
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 21 additions and 1 deletions

View file

@ -349,7 +349,7 @@ Functions
This function only includes canonical zone names and does not include This function only includes canonical zone names and does not include
"special" zones such as those under the ``posix/`` and ``right/`` "special" zones such as those under the ``posix/`` and ``right/``
directories, or the ``posixrules`` zone. directories, the ``posixrules`` or the ``localtime`` zone.
.. caution:: .. caution::

View file

@ -1951,6 +1951,21 @@ def test_exclude_posixrules(self):
actual = self.module.available_timezones() actual = self.module.available_timezones()
self.assertEqual(actual, expected) self.assertEqual(actual, expected)
def test_exclude_localtime(self):
expected = {
"America/New_York",
"Europe/London",
}
tree = list(expected) + ["localtime"]
with tempfile.TemporaryDirectory() as td:
for key in tree:
self.touch_zone(key, td)
with self.tzpath_context([td]):
actual = self.module.available_timezones()
self.assertEqual(actual, expected)
class CTestModule(TestModule): class CTestModule(TestModule):
module = c_zoneinfo module = c_zoneinfo

View file

@ -177,6 +177,10 @@ def valid_key(fpath):
# posixrules is a special symlink-only time zone where it exists, it # posixrules is a special symlink-only time zone where it exists, it
# should not be included in the output # should not be included in the output
valid_zones.remove("posixrules") valid_zones.remove("posixrules")
if "localtime" in valid_zones:
# localtime is a special symlink-only time zone where it exists, it
# should not be included in the output
valid_zones.remove("localtime")
return valid_zones return valid_zones

View file

@ -0,0 +1 @@
Removed ``localtime`` from the list of reported system timezones.