BUG: Fix failing hash function for certain non-ns resolution Timedelta
s by harahu · Pull Request #54037 · pandas-dev/pandas (original) (raw)
I noticed that hashing certain large pd.Timedelta
s 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.
- Tests added and passed if fixing a bug or adding a new feature
- All code checks passed.
- Added an entry in the latest
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.