gh-152212: Reject a POSIX TZ footer with a missing std offset in pure-Python zoneinfo#152213
Open
tonghuaroot wants to merge 1 commit into
Open
gh-152212: Reject a POSIX TZ footer with a missing std offset in pure-Python zoneinfo#152213tonghuaroot wants to merge 1 commit into
tonghuaroot wants to merge 1 commit into
Conversation
…n pure-Python zoneinfo The pure-Python _parse_tz_str defaulted a missing std offset to 0, so a POSIX TZ footer with a bare std abbreviation and no offset (e.g. 'AAA') was silently accepted as a fixed offset-0 zone. POSIX requires the offset after std, and the C accelerator already rejects it, so the pure-Python parser now raises ValueError to match.
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
zoneinfo._parse_tz_strdefaults a missing std offset to0(else: std_offset = 0), so a POSIX TZ footer with a bare std abbreviation and no offset (AAA,A,AA,B) is silently accepted as a fixed offset-0 zone. POSIX requires the offset afterstd(Issue 8 §8.3), and the C accelerator already raisesValueError: Invalid STD offset, so this makes the pure-Python parser raise to match.Adds
AAA/A/AA/Btotest_invalid_tzstr, which runs against bothTZStrTest(pure) andCTZStrTest(C). Non-breaking: all 598 IANA zones still parse, and well-formed strings (EST5,<ABC>5,AAA5) are unaffected.Fixes #152212.
zoneinfo: pure-Python parser accepts a POSIX TZ footer with no STD offset (C rejects) #152212