https://github.com/python/cpython/commit/41f5b920e436408c5412b598823e80000c62064b
commit: 41f5b920e436408c5412b598823e80000c62064b
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: StanFromIreland <[email protected]>
date: 2026-06-26T12:08:15Z
summary:

[3.15] gh-152246: Fix pure-Python `zoneinfo` accepting invalid seperators in 
POSIX TZ rules (GH-152247) (#152265)

(cherry picked from commit f47acc7f0920cb5ef507352172914876cea18a48)

Co-authored-by: tonghuaroot (童话) <[email protected]>
Co-authored-by: Stan Ulbrych <[email protected]>

files:
A Misc/NEWS.d/next/Library/2026-06-26-12-50-26.gh-issue-152246.MfXMd1.rst
M Lib/test/test_zoneinfo/test_zoneinfo.py
M Lib/zoneinfo/_zoneinfo.py

diff --git a/Lib/test/test_zoneinfo/test_zoneinfo.py 
b/Lib/test/test_zoneinfo/test_zoneinfo.py
index 7502b120825fbce..d4d57b8f727584f 100644
--- a/Lib/test/test_zoneinfo/test_zoneinfo.py
+++ b/Lib/test/test_zoneinfo/test_zoneinfo.py
@@ -1184,6 +1184,11 @@ def test_invalid_tzstr(self):
             # Invalid weekday
             "AAA4BBB,M1.1.7/2,M2.1.1/2",
             "AAA4BBB,M1.1.1/2,M2.1.7/2",
+            # Invalid Mm.w.d separator
+            "AAA4BBB,M3.2X0,M11.1.0",
+            "AAA4BBB,M3.2.0,M11.1X0",
+            "AAA4BBB,M3.2-0,M11.1.0/3",
+            "AAA4BBB,M3.2.0/2,M11.1:0",
             # Invalid numeric offset
             "AAA4BBB,-1/2,20/2",
             "AAA4BBB,1/2,-1/2",
diff --git a/Lib/zoneinfo/_zoneinfo.py b/Lib/zoneinfo/_zoneinfo.py
index 7063eb6a9025ac2..3903d57d55417e3 100644
--- a/Lib/zoneinfo/_zoneinfo.py
+++ b/Lib/zoneinfo/_zoneinfo.py
@@ -707,7 +707,7 @@ def _parse_dst_start_end(dststr):
     type = date[:1]
     if type == "M":
         n_is_julian = False
-        m = re.fullmatch(r"M(\d{1,2})\.(\d).(\d)", date, re.ASCII)
+        m = re.fullmatch(r"M(\d{1,2})\.(\d)\.(\d)", date, re.ASCII)
         if m is None:
             raise ValueError(f"Invalid dst start/end date: {dststr}")
         date_offset = tuple(map(int, m.groups()))
diff --git 
a/Misc/NEWS.d/next/Library/2026-06-26-12-50-26.gh-issue-152246.MfXMd1.rst 
b/Misc/NEWS.d/next/Library/2026-06-26-12-50-26.gh-issue-152246.MfXMd1.rst
new file mode 100644
index 000000000000000..0858199a9fa2798
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2026-06-26-12-50-26.gh-issue-152246.MfXMd1.rst
@@ -0,0 +1,2 @@
+Fix the pure-Python :mod:`zoneinfo` parser accepting an invalid POSIX TZ
+transition rule with a non-period separator. Patch by tonghuaroot.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to