Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 93454fe

Browse filesBrowse files
authored
gh-152212: Reject a POSIX TZ footer with a missing std offset in pure-Python zoneinfo (#152213)
1 parent b3154aa commit 93454fe
Copy full SHA for 93454fe

3 files changed

+10-1Lines changed: 10 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Lib/test/test_zoneinfo/test_zoneinfo.py‎

Copy file name to clipboardExpand all lines: Lib/test/test_zoneinfo/test_zoneinfo.py
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,11 @@ def test_extreme_tzstr(self):
11421142
def test_invalid_tzstr(self):
11431143
invalid_tzstrs = [
11441144
"PST8PDT", # DST but no transition specified
1145+
# gh-152212: the std offset is required (POSIX TZ grammar)
1146+
"AAA",
1147+
"A",
1148+
"AA",
1149+
"B",
11451150
"+11", # Unquoted alphanumeric
11461151
"GMT,M3.2.0/2,M11.1.0/3", # Transition rule but no DST
11471152
"GMT0+11,M3.2.0/2,M11.1.0/3", # Unquoted alphanumeric in DST
Collapse file

‎Lib/zoneinfo/_zoneinfo.py‎

Copy file name to clipboardExpand all lines: Lib/zoneinfo/_zoneinfo.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,8 @@ def _parse_tz_str(tz_str):
672672
except ValueError as e:
673673
raise ValueError(f"Invalid STD offset in {tz_str}") from e
674674
else:
675-
std_offset = 0
675+
# The STD offset is required
676+
raise ValueError(f"Invalid STD offset in {tz_str}")
676677

677678
if dst_abbr is not None:
678679
if dst_offset := m.group("dstoff"):
Collapse file
+3Lines changed: 3 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix the pure-Python :mod:`zoneinfo` parser accepting a POSIX TZ string with a
2+
``std`` abbreviation but no offset. This is invalid per POSIX and now
3+
raises :exc:`ValueError`, matching the C accelerator. Patch by tonghuaroot.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.