Closed
Description
Bug report
Bug description:
import zoneinfo
zoneinfo.ZoneInfo('')
results in the following exception:
>>> zoneinfo.ZoneInfo('')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/asottile/.pyenv/versions/3.11.6/lib/python3.11/zoneinfo/_tzpath.py", line 67, in find_tzfile
_validate_tzfile_path(key)
File "/Users/asottile/.pyenv/versions/3.11.6/lib/python3.11/zoneinfo/_tzpath.py", line 91, in _validate_tzfile_path
raise ValueError(
ValueError: ZoneInfo keys must be normalized relative paths, got:
I expect zoneinfo.ZoneInfoNotFound
instead, or some other error that's more specific about this case
it seems this stems from the code internally using the length of the normpath
'd result of this string and:
>>> normpath('')
'.'
a small improvement would be to use !r
in the error message as well
CPython versions tested on:
3.11, CPython main branch
Operating systems tested on:
macOS
Linked PRs
- gh-114713: handle case of an empty string passed to ZoneInfo #114731
- [3.13] gh-114713: Handle case of an empty string passed to
zoneinfo.ZoneInfo
(GH-114731) #132563 - gh-114713: Handle case of an empty bytes object passed to
zoneinfo.ZoneInfo
#132582 - gh-114713: Revert gh-114731 #133330
- [3.13] gh-114713: Revert gh-114731 (GH-133330) #133331
Metadata
Metadata
Assignees
Projects
Status
Done