Files
youknowdot 59b36dd426 _zoneinfo: reject empty quoted POSIX TZ abbreviations (#9017)
* Reject empty quoted POSIX timezone abbreviations

Split the Python 3.14-compatible parser guard from #8954. Cover empty standard and daylight-saving abbreviations and preserve valid quoted names.

Assisted-by: OpenAI Codex:model identifier unavailable

* Keep zoneinfo regression in module snippet

Rename the snippet as requested during review without changing test contents.

Assisted-by: OpenAI Codex:model identifier unavailable
2026-10-09 23:29:16 +09:00

20 lines
563 B
Python

import io
import struct
from zoneinfo import ZoneInfo
from testutils import assert_raises
# Minimal TZif v3 data with no transitions and a POSIX rule in the footer.
header = (b"TZif3" + b"\0" * 15 + struct.pack(">6l", 0, 0, 0, 0, 0, 0)) * 2
def zone_from_rule(rule):
return ZoneInfo.from_file(io.BytesIO(header + b"\n" + rule + b"\n"))
for rule in (b"<>5", b"AAA4<>,M3.2.0/2,M11.1.0/3"):
assert_raises(ValueError, zone_from_rule, rule)
# Quoting still permits nonempty numeric abbreviations.
assert zone_from_rule(b"<+05>-5").tzname(None) == "+05"