Skip to content

fix: pickling DateTime - #909

Open
ruaridhw wants to merge 1 commit into
python-pendulum:masterfrom
ruaridhw:patch-1
Open

ruaridhw wants to merge 1 commit into
python-pendulum:masterfrom
ruaridhw:patch-1

Conversation

@ruaridhw

Copy link
Copy Markdown

Pickling pendulum DateTimes doesn't preserve before vs after DST effects. See #908

Pull Request Check List

  • Added tests for changed code.
  • Updated documentation for changed code.

Pickling pendulum DateTimes doesn't preserve before vs after DST effects.
See python-pendulum#908
@ruaridhw ruaridhw mentioned this pull request Aug 12, 2025
2 tasks done
@ashb

ashb commented Aug 12, 2025

Copy link
Copy Markdown
Member

Please add some unit tests to prevent regressions

@codspeed

codspeed Bot commented Aug 18, 2025

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #909 will not alter performance

Comparing ruaridhw:patch-1 (63a658f) with master (2adcc02)

Summary

✅ 1 untouched benchmarks

@Duo-ee

Duo-ee commented Oct 28, 2026

Copy link
Copy Markdown

Heads-up: I opened #1073 as a fix for #908 that also carries the regression tests this PR was asked for.

One thing worth knowing about restoring through self.create: it re-resolves the wall time in the timezone instead of rebuilding the instance, so it also changes things beyond the fold. On master, with your patch applied locally, I measured:

  • a zoneinfo.ZoneInfo tzinfo comes back as FixedTimezone/Timezone
  • a wall time that does not exist (2024-03-10 02:30 in America/Chicago, only reachable through the constructor) is moved to 01:30, so its timestamp changes by an hour

#1073 keeps create() out of the path and rebuilds via cls(*state, fold=fold).

Not asking you to do anything with this PR; if you would rather land the fix here, the tests in #1073 apply as they are.

This branch has not been deployed

No deployments
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.

4 participants