BUG: Fix failing hash function for certain non-ns resolution Timedeltas by harahu · Pull Request #54037 · pandas-dev/pandas (original) (raw)

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.