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

[3.14] gh-152212: Reject a POSIX TZ footer with a missing std offset in pure-Python `zoneinfo` (GH-152213) by miss-islington · Pull Request #152378 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 5 additions & 0 deletions Lib/test/test_zoneinfo/test_zoneinfo.py
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
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,11 @@ def test_extreme_tzstr(self):
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
Expand Down
3 changes: 2 additions & 1 deletion Lib/zoneinfo/_zoneinfo.py
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
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,8 @@ def _parse_tz_str(tz_str):
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"):
Expand Down
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
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.
Loading

Back | FazBrowse Home | New Git URL