Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Fix failing hash function for certain non-ns resolution Timedeltas #54037

Merged
merged 5 commits into from
Jul 7, 2023

Conversation

harahu
Copy link
Contributor

@harahu harahu commented Jul 7, 2023

I noticed that hashing certain large pd.Timedeltas resultet in an OutOfBoundsTimedelta exception, which shouldn't happen.

In the hash implementation there is seems to be an attempt at catching this error, as the offending line is wrapped in a try clause, but, the except clause catches an OverflowError instead. The call that raises OutOfBoundsTimedelta does so when itself catches an OverflowError, so my interpretation is that the intention was for the hash implementation to catch the OutOfBoundsTimedelta. My changes reflect this. I've also added a test reproducing the issue.

@harahu harahu marked this pull request as ready for review July 7, 2023 15:45
@harahu harahu requested a review from MarcoGorelli as a code owner July 7, 2023 15:45
@mroeschke mroeschke added the Non-Nano datetime64/timedelta64 with non-nanosecond resolution label Jul 7, 2023
Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be good, thanks @harahu !

@mroeschke mroeschke added this to the 2.1 milestone Jul 7, 2023
@mroeschke mroeschke merged commit bdbe4d2 into pandas-dev:main Jul 7, 2023
@mroeschke
Copy link
Member

Thanks @harahu

Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
…ta`s (pandas-dev#54037)

* Add reproducing test

* Attempt fix

* Add GH reference

* Add whatsnew entry

* Pre-commit after the fact
@harahu harahu changed the title BUG: Fix failing hash funciton for certain non-ns resolution Timedeltas BUG: Fix failing hash function for certain non-ns resolution Timedeltas Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Non-Nano datetime64/timedelta64 with non-nanosecond resolution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants