mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
* 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
20 lines
563 B
Python
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"
|