Repository navigation
Conversation
Muguett-DBY
left a comment
There was a problem hiding this comment.
I checked 0a607ed with the clock fixed at 2010-02-02. The three added cases produce the expected strings with this change; the previous _abs_timedelta raises OverflowError for all three. For 505 smaller positive and negative durations, both naturaltime and precisedelta matched the previous implementation (1,010 comparisons).
One existing limit is separate from the helper this changes: with the same clock, precisedelta(timedelta(days=-3_000_000)) still raises OverflowError on both the base and this branch. _date_and_delta first computes now - value, which exceeds the maximum datetime, before _abs_timedelta is called. The same limit applies to naturaltime. This isn't a regression in this PR; it may be useful to keep the description scoped to the cases fixed here or track that boundary separately.
I ran the checked-out project source on Windows / Python 3.12 with the clock mocked and generated version metadata supplied in memory. I did not run pytest, freezegun, tox or the full suite. Review and validation assisted by Codex.
Fixes an OverflowError in naturaltime() and precisedelta() for far-future dates such as datetime(9999, 12, 31) by using abs(delta) in _abs_timedelta(). Adds regression tests.