mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
gh-114713: Handle case of an empty string passed to zoneinfo.ZoneInfo (#114731)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
This commit is contained in:
parent
f3192dac66
commit
884df116d7
3 changed files with 7 additions and 0 deletions
|
|
@ -236,6 +236,7 @@ def test_bad_keys_paths(self):
|
|||
"../zoneinfo/America/Los_Angeles", # Traverses above TZPATH
|
||||
"America/../America/Los_Angeles", # Not normalized
|
||||
"America/./Los_Angeles",
|
||||
"",
|
||||
]
|
||||
|
||||
for bad_key in bad_keys:
|
||||
|
|
|
|||
|
|
@ -83,6 +83,11 @@ def find_tzfile(key):
|
|||
|
||||
|
||||
def _validate_tzfile_path(path, _base=_TEST_PATH):
|
||||
if not path:
|
||||
raise ValueError(
|
||||
"ZoneInfo key must not be an empty string"
|
||||
)
|
||||
|
||||
if os.path.isabs(path):
|
||||
raise ValueError(
|
||||
f"ZoneInfo keys may not be absolute paths, got: {path}"
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
Handle case of an empty string passed to :class:`zoneinfo.ZoneInfo`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue