Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-114713: Handle case of an empty bytes object passed tozoneinfo.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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Eclips4 wants to merge4 commits intopython:main
base:main
Choose a base branch
Loading
fromEclips4:issue-114731

Conversation

Eclips4
Copy link
Member

@Eclips4Eclips4 commentedApr 16, 2025
edited
Loading

@Eclips4Eclips4 changed the titlegh-114731: Handle case of an empty bytes object passed tozoneinfo.ZoneInfogh-114713: Handle case of an empty bytes object passed tozoneinfo.ZoneInfoApr 16, 2025
@@ -83,10 +83,14 @@ def find_tzfile(key):


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

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 passNone, instead of aTypeError we'll get aValueError, so we need more exact check here.

@Eclips4Eclips4 added the needs backport to 3.13bugs and security fixes labelApr 16, 2025
Comment on lines +90 to +93
elif isinstance(path, bytes) and path == b"":
raise ValueError(
"ZoneInfo key must not be an empty bytes object"
)
Copy link
Contributor

@WolframAlphWolframAlphApr 16, 2025
edited
Loading

Choose a reason for hiding this comment

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

Does it make sense maybe to just emitZoneInfo key must not be empty for both string and bytes? Also, since we check for passed data types, does it make sense to also restrict them to str/bytes? Currently, passing for instance[] results inTypeError: unhashable type: 'list' somewhere down the road. Maybe worth returning meaningful exception saying what allowed types are? We anyway check passed in types.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The 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.
We should insert these two checks (actually, bytes objects shouldn't be passed to thezoneinfo.ZoneInfo) to C and Python implementation ofZoneInfo.__new__:

  1. Check thatkey is string (or subclass of string)
  2. Check thatkey is a non-empty string.
    WDYM?

@serhiy-storchakaserhiy-storchaka added the needs backport to 3.14bugs and security fixes labelMay 8, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@WolframAlphWolframAlphWolframAlph left review comments

Assignees
No one assigned
Labels
awaiting core reviewneeds backport to 3.13bugs and security fixesneeds backport to 3.14bugs and security fixes
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@Eclips4@WolframAlph@serhiy-storchaka

[8]ページ先頭

©2009-2025 Movatter.jp