Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Lib/test/test_zoneinfo/test_zoneinfo.py
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",

@StanFromIreland StanFromIreland Jun 26, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to say these are rejected for another reason, i.e. because of the spec's required length:

three byte minimum length

But of course, we don't enforce that. However, I'm also not sure if this is just part of the 2024 updated spec, and I don't have time to check right now. I'll put this on my to-do list.

"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
2 changes: 1 addition & 1 deletion Lib/zoneinfo/_zoneinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ 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
raise ValueError(f"Invalid STD offset in {tz_str}")
Comment thread
StanFromIreland marked this conversation as resolved.

if dst_abbr is not None:
if dst_offset := m.group("dstoff"):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Fixed a parity bug in the pure-Python :mod:`zoneinfo` implementation, which
accepted a POSIX TZ footer whose ``std`` field had no offset (for example
``AAA``), silently building a fixed offset-0 zone. Such a string is invalid per
POSIX (the offset following ``std`` is required), and the C accelerator already
rejects it; the pure-Python parser now raises :exc:`ValueError` to match.
Patch by tonghuaroot.
Comment thread
StanFromIreland marked this conversation as resolved.
Outdated
Loading