Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Lib/test/test_zoneinfo/test_zoneinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ def test_bad_keys_paths(self):
"America/../America/Los_Angeles", # Not normalized
"America/./Los_Angeles",
"",
b"",
]

for bad_key in bad_keys:
Expand Down
6 changes: 5 additions & 1 deletion Lib/zoneinfo/_tzpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,14 @@ def find_tzfile(key):


def _validate_tzfile_path(path, _base=_TEST_PATH):
if not path:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't correct.
If we pass None, instead of a TypeError we'll get a ValueError, so we need more exact check here.

if path == "":
raise ValueError(
"ZoneInfo key must not be an empty string"
)
elif path == b"":
raise ValueError(
"ZoneInfo key must not be an empty bytes object"
)

if os.path.isabs(path):
raise ValueError(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Handle case of an empty bytes object passed to :class:`zoneinfo.ZoneInfo`.

Loading