Repository navigation
Conversation
Wkhanex
reviewed
Oct 13, 2026
There was a problem hiding this comment.
96 datetime/time copy and pickle checks passed across naive, UTC and America/New_York zones, fold=0/fold=1, pickle protocols 0–5, copy.copy and copy.deepcopy. I used Python 3.12.14 against commit a49c951.
Protocols 4/5 and both copy operations preserved fold, while protocols 0–3 lost it consistently with the standard-library temporal types. Serialized text and tzinfo were preserved in these cases. The New York fold=1 datetime is a useful regression because losing fold changes its UTC offset, not just an attribute. These were standalone assertions against fetched PR source, not a full pytest run.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Copying or pickling a
DateTimeitem created from an ambiguous local datetime dropsfold=1. For example, the later 01:30 during a DST rollback becomes the earlier 01:30, changing the timestamp by an hour while retaining the original rendered TOML.Timeitems also lose their fold.Preserve fold in the datetime and time pickle constructor arguments for protocols 4 and later, matching PEP 495 and the standard-library types. This also fixes shallow and deep copying. Default fold-zero values keep their original pickle bytes and constructor representation. Tests compare all supported pickle protocols with the corresponding stdlib value, check both fold values, and retain the rendered value and comment trivia. The existing fold-sensitive timezone fixture is moved to module scope so it can be pickled.
Validation on Linux / CPython 3.12.13:
Other platforms and Python versions were not run locally.
Agent Drafting Metadata