-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-114713: Handle case of an empty bytes object passed to zoneinfo.ZoneInfo
#132582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,10 +83,14 @@ def find_tzfile(key): | |
|
||
|
||
def _validate_tzfile_path(path, _base=_TEST_PATH): | ||
if not path: | ||
if isinstance(path, str) and path == "": | ||
raise ValueError( | ||
"ZoneInfo key must not be an empty string" | ||
) | ||
elif isinstance(path, bytes) and path == b"": | ||
raise ValueError( | ||
"ZoneInfo key must not be an empty bytes object" | ||
) | ||
Comment on lines
+90
to
+93
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it make sense maybe to just emit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that makes sense. Though I think that the current approach is wrong.
|
||
|
||
if os.path.isabs(path): | ||
raise ValueError( | ||
|
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`. | ||
|
There was a problem hiding this comment.
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 aTypeError
we'll get aValueError
, so we need more exact check here.