Repository navigation
Conversation
Compare and hash retained TZif bytes for unnamed zones so distinct local timezone files no longer collapse in sets and dictionaries. Preserve named-zone behavior. AI assistance: OpenAI Codex.
Merging this PR will not alter performance
|
Wkhanex
left a comment
There was a problem hiding this comment.
The content-based distinction also holds when two unnamed zones happen to share the current UTC offset. On beb8f70, an unnamed Europe/London zone and an unnamed UTC zone both have offset zero in January 2024, but remain unequal and occupy two set entries, preserving their different rule histories. I additionally checked UTC, Paris, New York and Kathmandu through every available pickle protocol: 24 round trips preserved equality, hash and dictionary lookup, and January/July offsets matched ZoneInfo. The timezone module passed 46 tests with its two existing POSIX-transition skips. Python 3.12/pure-Python mode only; no full-suite or native-backend claim.
Review and local validation prepared with OpenAI Codex assistance.
Pull Request Check List
Fix
Unnamed TZif-backed timezones all have
key=None, so the current key-only equality makes distinct Paris/UTC/New York files equal and collapses them into one set/dictionary entry. This also affects the existing local-timezone fallback for copied/etc/localtimefiles.Compare and hash the TZif bytes already retained for pickling when the key is absent. Independent loads of identical bytes and pickle round trips remain equal. Named/keyed timezone behavior and FixedTimezone are unchanged.
Twelve new cases cover distinct and identical files, collections, all pickle protocols, named/keyed/uncached controls, unrelated objects and copied-localtime discovery. Documentation explains the rule.
Validation
Linux/Python 3.12.14, unchanged dependencies and pinned hooks:
Existing Windows/timezone skips, INFO-level docs anchor notices and Cargo metadata warning are unchanged. Other Python/OS combinations and hosted CI are not claimed passed. Prepared and tested with AI assistance (OpenAI Codex); no human review is claimed.