gh-99772: Fix datetime.time comparison and hashing for sub-minute UTC offsets - #155024
Open
yangbaechu wants to merge 1 commit into
Open
gh-99772: Fix datetime.time comparison and hashing for sub-minute UTC offsets#155024yangbaechu wants to merge 1 commit into
yangbaechu wants to merge 1 commit into
Conversation
…ute UTC offsets Normalize the complete UTC offset in the C and pure Python comparison paths, and align the pure Python hash with the C implementation. Add shared regression tests for both implementations.
saitejabandaru-in
left a comment
There was a problem hiding this comment.
Looks good to me. The logic correctly handles the sub-minute UTC offset conversions by normalizing to microseconds across both the Python and C implementations, and the tests adequately cover equality, ordering, and hashing for these edge cases. Thanks for fixing this!
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.
closes #155023.
This PR fixes
datetime.timecomparison and hashing when UTC offsets contain seconds or microseconds.The C comparison now includes the complete offset by normalizing each time to signed microseconds. The pure Python comparison uses the same integer normalization, and its hash uses the normalized value
wall time - UTC offset.The shared tests cover equality, ordering, and hashing with second and microsecond offsets, including a negative microsecond offset. They run against both the C and pure Python implementations.
datetime.timecomparisons and hashing mishandle sub-minute UTC offsets #155023