gh-152248: Reject a POSIX TZ abbreviation with non-ASCII-letter characters in pure-Python zoneinfo#152249
Open
tonghuaroot wants to merge 6 commits into
Open
gh-152248: Reject a POSIX TZ abbreviation with non-ASCII-letter characters in pure-Python zoneinfo#152249tonghuaroot wants to merge 6 commits into
tonghuaroot wants to merge 6 commits into
Conversation
… characters in pure-Python zoneinfo
StanFromIreland
approved these changes
Jun 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The pure-Python
zoneinfoparser accepts a POSIX TZ string whose unquoted std/dst abbreviation contains characters other than ASCII letters (for example an embedded space or a non-ASCII letter), while the C implementation rejects it. The unquoted alternative in the parser regex is a negated class ([^<0-9:.+-]+) that admits anything except a few delimiters, whereas the Cparse_abbrwalks the unquoted form withPy_ISALPHA(ASCII letters only), as POSIX (via RFC 8536) requires for the unquoted form.This tightens the unquoted alternative to
[a-zA-Z]+, matching the C accelerator and POSIX, and leaves the quoted<...>form untouched. Every well-formed TZ string and all bundled IANA zones still parse unchanged; only the previously-accepted strings now raiseValueError.The non-ASCII case is reachable through the public
from_filepath, which UTF-8-decodes the footer, so it is covered by a dedicated regression test in addition to the whitespace cases added to the sharedinvalid_tzstrslist.