Repository navigation
Fix fractional-second parsing in parse_iso8601 - #11181
Open
adityajai119 wants to merge 1 commit into
Open
adityajai119 wants to merge 1 commit into
adityajai119 wants to merge 1 commit into
Conversation
atishay-kasliwal
left a comment
There was a problem hiding this comment.
Compared parse_iso8601 with datetime.fromisoformat on 7 timestamps with 0, 1, 2, 6 and 7 fraction digits, with and without an offset. All match now. Master turned .5 into 5 microseconds and raised ValueError for 7 digits.
This branch has not been deployed
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.
parse_iso8601converted the fractional-second digits directly to an integer microsecond value, so.1became 1 microsecond instead of 100000 and.12became 12 instead of 120000. That disagrees withdatetime.datetime.fromisoformatanddateutil.parser.isoparse, the replacements named in the deprecation warning.The fractional part is now right-padded to six digits (and truncated beyond six) before conversion.
Verification:
pytest t/unit/utils/test_iso8601.py10 passed;ruff check celery/utils/iso8601.py t/unit/utils/test_iso8601.pyclean.