Skip to content

fix: avoid OverflowError in naturaltime for far-future dates#353

Open
santhreal wants to merge 2 commits into
python-humanize:mainfrom
santhreal:fix/abs-timedelta-no-datetime-math
Open

fix: avoid OverflowError in naturaltime for far-future dates#353
santhreal wants to merge 2 commits into
python-humanize:mainfrom
santhreal:fix/abs-timedelta-no-datetime-math

Conversation

@santhreal

@santhreal santhreal commented Jul 18, 2026

Copy link
Copy Markdown

humanize.time._abs_timedelta hits OverflowError when naturaltime far-future datetime underflows via now+delta. This PR fixes the regression with a focused test covering the case.

_abs_timedelta used now-(now+delta), which underflows below year 1 for
large negative deltas. Negate the timedelta directly instead.
Ship only the _abs_timedelta negation fix; the timedelta Overflow
fallback was out of scope for the far-future naturaltime crash.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant