Skip to content

gh-152212: Reject a POSIX TZ footer with a missing std offset in pure-Python zoneinfo#152213

Open
tonghuaroot wants to merge 1 commit into
python:mainfrom
tonghuaroot:fix-gh-152212-zoneinfo-std-offset
Open

gh-152212: Reject a POSIX TZ footer with a missing std offset in pure-Python zoneinfo#152213
tonghuaroot wants to merge 1 commit into
python:mainfrom
tonghuaroot:fix-gh-152212-zoneinfo-std-offset

Conversation

@tonghuaroot

@tonghuaroot tonghuaroot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

The pure-Python zoneinfo._parse_tz_str defaults a missing std offset to 0 (else: std_offset = 0), so a POSIX TZ footer with a bare std abbreviation and no offset (AAA, A, AA, B) is silently accepted as a fixed offset-0 zone. POSIX requires the offset after std (Issue 8 §8.3), and the C accelerator already raises ValueError: Invalid STD offset, so this makes the pure-Python parser raise to match.

Adds AAA/A/AA/B to test_invalid_tzstr, which runs against both TZStrTest (pure) and CTZStrTest (C). Non-breaking: all 598 IANA zones still parse, and well-formed strings (EST5, <ABC>5, AAA5) are unaffected.

Fixes #152212.

…n pure-Python zoneinfo

The pure-Python _parse_tz_str defaulted a missing std offset to 0, so a POSIX TZ
footer with a bare std abbreviation and no offset (e.g. 'AAA') was silently accepted
as a fixed offset-0 zone.  POSIX requires the offset after std, and the C accelerator
already rejects it, so the pure-Python parser now raises ValueError to match.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zoneinfo: pure-Python parser accepts a POSIX TZ footer with no STD offset (C rejects)

1 participant