gh-152246: Fix pure-Python zoneinfo accepting invalid seperators in POSIX TZ (Mm.w.d) rules#152247
Merged
StanFromIreland merged 4 commits intoJun 26, 2026
Conversation
…rator in pure-Python zoneinfo
StanFromIreland
approved these changes
Jun 26, 2026
Co-authored-by: Stan Ulbrych <stan@python.org>
Member
|
The POSIX spec isn't actually explicit here, and doesn’t provide a formal grammar, but this is clearly a regex-typo (and doesn’t really make much sense in practice to allow other separators). Additionally, it's consistent with the far more used C implementation. As such, LGTM. |
zoneinfo accepting invalid seperators in POSIX TZ (Mm.w.d) rules
|
Thanks @tonghuaroot for the PR, and @StanFromIreland for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15. |
|
GH-152265 is a backport of this pull request to the 3.15 branch. |
|
GH-152266 is a backport of this pull request to the 3.14 branch. |
|
GH-152267 is a backport of this pull request to the 3.13 branch. |
Member
|
Merged, thanks. |
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 accepted a POSIX TZMm.w.dtransition rule whose third separator was not a period. Only the first separator is escaped in the regex (r"M(\d{1,2})\.(\d).(\d)"); the bare third.matches any single character, so for exampleEST5EDT,M3.2X0,M11.1.0was accepted withXconsumed as the separator. POSIX requires literal periods and the C accelerator already rejects these strings, so this is a pure-vs-C parity bug.This escapes the third separator (
\.) so the pure parser matches the C accelerator and POSIX. Every well-formedMm.w.drule and all bundled IANA zones still parse; only the previously-accepted malformed separators now raiseValueError.Mm.w.drule accepts a non-.week/day separator (C rejects) #152246