Repository navigation
Fix serialization of dates and times created by factory methods - #707
Open
liugedragon wants to merge 1 commit into
Open
liugedragon wants to merge 1 commit into
liugedragon wants to merge 1 commit into
Conversation
|
🛡️ Human Attestation required. A human needs to confirm this PR once before it can merge. Attest this PR — sign in with GitHub, pass the challenge, and confirm one of the statements. |
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
Date.fromisoformat(),Date.fromordinal()and the other inherited date factories return TOML items with an empty_rawvalue.Time.fromisoformat()does the same. Serializing one producesvalue = \n, which both Tomlkit and stdlibtomllibreject.When no source text was supplied, generate the date's ISO text or use the existing local-time formatter. This follows the fallback already used by
DateTime; parsed items retain their original text and comments.Fifteen regressions cover date/time factories, fractional seconds, existing raw formatting and the unchanged DateTime behavior. On Python 3.11+, serialization is checked with the independent stdlib parser as well as Tomlkit. Before the fix: 11 failed, 4 passed. After the fix: all pass.
Validation on Windows / Python 3.13.4:
Duplicate Check
Time. This change does not replace that trivia fix. tests: stop using parse_rfc3339 as the toml-test datetime oracle #639 changes conformance-test oracles, not factory serialization.Agent Drafting Metadata