Skip to content

gh-159708: Bound recurring zoneinfo rules by the last explicit transition - #159833

Open
limadog9 wants to merge 1 commit into
python:mainfrom
limadog9:gh-159708-zoneinfo-footer-boundary
Open

limadog9 wants to merge 1 commit into
python:mainfrom
limadog9:gh-159708-zoneinfo-footer-boundary

Conversation

@limadog9

@limadog9 limadog9 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #159708.

Near the last explicit TZif transition, the recurring footer can select an offset that maps a local time to a UTC instant before the footer applies. In America/Nuuk, this makes an ordinary local time use the wrong offset and change by an hour on a UTC round trip.

Check the implied UTC instant before accepting the recurring rule's result; use the final explicit time type if that instant precedes the last transition. Apply the same check in the C and Python implementations.

The regression uses generated TZif data for single-transition and multiple-transition files. It checks offsets, DST, names, and UTC round trips around the boundary with both fold values, without depending on system timezone data.

Validation on Linux x86-64 debug builds:

  • The regression fails in eight subcases on unmodified main, covering both implementations, and passes with the fix.
  • test_zoneinfo and test_datetime passed in GIL and free-threaded builds (1,445 test cases each, 33 skips; tzdata==2025.3 available).
  • ./python -m test -R 3:3 -m test_footer_fold_at_last_transition test_zoneinfo passed with no reference leaks in both builds.
  • Ruff, NEWS reStructuredText lint, patchcheck, and git diff --check passed.

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.utcoffset() gives the wrong offset near the last explicit TZif transition

1 participant