Skip to content

Fix #524: return non-finite floats unchanged from naturaltime() and precisedelta() - #525

Open
tony1233200 wants to merge 1 commit into
python-humanize:mainfrom
tony1233200:fix-524-non-finite-naturaltime-precisedelta
Open

tony1233200 wants to merge 1 commit into
python-humanize:mainfrom
tony1233200:fix-524-non-finite-naturaltime-precisedelta

Conversation

@tony1233200

Copy link
Copy Markdown

naturaltime(float("inf")) and precisedelta(float("inf")) raised OverflowError, while naturaldelta() returns "inf" since #334. This mirrors that handling in the shared _date_and_delta() helper: non-finite floats (inf/-inf) are now returned unchanged as their string, like nan already was. A too-large finite value (e.g. 1e30) still raises OverflowError, per the documented contract.

Tests: added test_naturaltime_non_finite, test_naturaltime_too_large_value_raises, test_precisedelta_non_finite, test_precisedelta_too_large_value_raises, plus assertions in test_date_and_delta for both the rounded and precise paths. tests/test_time.py: 403 passed; full suite: 755 passed.

…raltime() and precisedelta()

Mirror the naturaldelta() handling from python-humanize#334 in the shared
_date_and_delta() helper: non-finite floats (inf/-inf) are returned
unchanged as their string instead of raising OverflowError, while a
too-large finite value still raises. nan already behaved this way via
the ValueError path.
@agentscanapp

agentscanapp Bot commented Nov 27, 2026

Copy link
Copy Markdown

Mixed activity

Activity patterns show a mix of organic and automated signals.

View full analysis →

Evidence
  • Closed PRs across many repositories: 16 PRs were closed across 14 repositories in 7d.

Last 5 PRs:

This is an automated analysis by AgentScan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant