FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-152246: Fix pure-Python `zoneinfo` accepting invalid seperators in POSIX TZ (`Mm.w.d`) rules by tonghuaroot · Pull Request #152247 · python/cpython · GitHub

Repository navigation

gh-152246: Fix pure-Python zoneinfo accepting invalid seperators in POSIX TZ (Mm.w.d) rules - #152247

Merged
StanFromIreland merged 4 commits into
python:mainfrom
tonghuaroot:gh-152246-zoneinfo-mmwd-separator
Jun 26, 2026
Merged

StanFromIreland merged 4 commits into
python:mainfrom
tonghuaroot:gh-152246-zoneinfo-mmwd-separator

Conversation

tonghuaroot commented Jun 26, 2026 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

The pure-Python zoneinfo parser accepted a POSIX TZ Mm.w.d transition 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 example EST5EDT,M3.2X0,M11.1.0 was accepted with X consumed 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-formed Mm.w.d rule and all bundled IANA zones still parse; only the previously-accepted malformed separators now raise ValueError.

Comment thread Lib/test/test_zoneinfo/test_zoneinfo.py Outdated
Co-authored-by: Stan Ulbrych <stan@python.org>

StanFromIreland commented Jun 26, 2026 •
edited
Loading

Copy link
Copy Markdown
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.

StanFromIreland changed the title gh-152246: Reject a POSIX TZ Mm.w.d rule with a non-period separator in pure-Python zoneinfo gh-152246: Fix pure-Python zoneinfo accepting invalid seperators in POSIX TZ (Mm.w.d) rules Jun 26, 2026
StanFromIreland added needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Jun 26, 2026
StanFromIreland merged commit f47acc7 into python:main Jun 26, 2026
104 of 106 checks passed

Copy link
Copy Markdown

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.
🐍🍒⛏🤖

bedevere-app Bot commented Jun 26, 2026

Copy link
Copy Markdown

GH-152265 is a backport of this pull request to the 3.15 branch.

bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Jun 26, 2026

bedevere-app Bot commented Jun 26, 2026

Copy link
Copy Markdown

GH-152266 is a backport of this pull request to the 3.14 branch.

bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jun 26, 2026

bedevere-app Bot commented Jun 26, 2026

Copy link
Copy Markdown

GH-152267 is a backport of this pull request to the 3.13 branch.

bedevere-app Bot removed the needs backport to 3.13 only security fixes label Jun 26, 2026

Copy link
Copy Markdown
Member

Merged, thanks.

StanFromIreland added a commit that referenced this pull request Jun 26, 2026
…tors in POSIX TZ rules (GH-152247) (#152267)

(cherry picked from commit f47acc7)

Co-authored-by: tonghuaroot (童话) <tonghuaroot@gmail.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
StanFromIreland added a commit that referenced this pull request Jun 26, 2026
…tors in POSIX TZ rules (GH-152247) (#152266)

(cherry picked from commit f47acc7)

Co-authored-by: tonghuaroot (童话) <tonghuaroot@gmail.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
StanFromIreland added a commit that referenced this pull request Jun 26, 2026
…tors in POSIX TZ rules (GH-152247) (#152265)

(cherry picked from commit f47acc7)

Co-authored-by: tonghuaroot (童话) <tonghuaroot@gmail.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL