def test_invalid_tzstr(self):
invalid_tzstrs = [
"PST8PDT", # DST but no transition specified
+ # gh-152212: the std offset is required (POSIX TZ grammar)
+ "AAA",
+ "A",
+ "AA",
+ "B",
"+11", # Unquoted alphanumeric
"GMT,M3.2.0/2,M11.1.0/3", # Transition rule but no DST
"GMT0+11,M3.2.0/2,M11.1.0/3", # Unquoted alphanumeric in DST
except ValueError as e:
raise ValueError(f"Invalid STD offset in {tz_str}") from e
else:
- std_offset = 0
+ # The STD offset is required
+ raise ValueError(f"Invalid STD offset in {tz_str}")
if dst_abbr is not None:
if dst_offset := m.group("dstoff"):
--- /dev/null
+Fix the pure-Python :mod:`zoneinfo` parser accepting a POSIX TZ string with a
+``std`` abbreviation but no offset. This is invalid per POSIX and now
+raises :exc:`ValueError`, matching the C accelerator. Patch by tonghuaroot.