Skip to content

Commit a3a3bfd

Browse files
miss-islingtonwrongnullStanFromIrelandEclips4
authored
[3.13] gh-114713: Handle case of an empty string passed to zoneinfo.ZoneInfo (GH-114731) (#132563)
gh-114713: Handle case of an empty string passed to `zoneinfo.ZoneInfo` (GH-114731) (cherry picked from commit 884df11) Co-authored-by: Bogdan Romanyuk <[email protected]> Co-authored-by: Stan Ulbrych <[email protected]> Co-authored-by: Kirill Podoprigora <[email protected]>
1 parent 11617d5 commit a3a3bfd

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

Lib/test/test_zoneinfo/test_zoneinfo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ def test_bad_keys_paths(self):
235235
"../zoneinfo/America/Los_Angeles", # Traverses above TZPATH
236236
"America/../America/Los_Angeles", # Not normalized
237237
"America/./Los_Angeles",
238+
"",
238239
]
239240

240241
for bad_key in bad_keys:

Lib/zoneinfo/_tzpath.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ def find_tzfile(key):
8383

8484

8585
def _validate_tzfile_path(path, _base=_TEST_PATH):
86+
if not path:
87+
raise ValueError(
88+
"ZoneInfo key must not be an empty string"
89+
)
90+
8691
if os.path.isabs(path):
8792
raise ValueError(
8893
f"ZoneInfo keys may not be absolute paths, got: {path}"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Handle case of an empty string passed to :class:`zoneinfo.ZoneInfo`.

0 commit comments

Comments
 (0)