]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-152246: Fix pure-Python `zoneinfo` accepting invalid seperators in POSIX...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 26 Jun 2026 12:04:35 +0000 (14:04 +0200)
committerGitHub <noreply@github.com>
Fri, 26 Jun 2026 12:04:35 +0000 (12:04 +0000)
(cherry picked from commit f47acc7f0920cb5ef507352172914876cea18a48)

Co-authored-by: tonghuaroot (童话) <tonghuaroot@gmail.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
Lib/test/test_zoneinfo/test_zoneinfo.py
Lib/zoneinfo/_zoneinfo.py
Misc/NEWS.d/next/Library/2026-06-26-12-50-26.gh-issue-152246.MfXMd1.rst [new file with mode: 0644]

index 9483c2fc512e0d1d854c13b5e27a7c3fc0cbe719..21033882e148a3962d0625bda1f5b3d02634e6b9 100644 (file)
@@ -1184,6 +1184,11 @@ class TZStrTest(ZoneInfoTestBase):
             # 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",
index 7063eb6a9025ac25e0266174ca1fb72774f446b0..3903d57d55417e3d260d4641d0156dc025868236 100644 (file)
@@ -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 (file)
index 0000000..0858199
--- /dev/null
@@ -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.