You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
naturaldelta() raises OverflowError on float('inf') instead of returning it unchanged #333
naturaldelta() documents that a non-finite float value is "returned unchanged." nan is handled (its int() raises ValueError, which is caught), but float('inf')/float('-inf') raise an uncaught OverflowError from int(value), because the except (ValueError, TypeError) clause omits OverflowError. The behavior is asymmetric and contradicts the docstring.
Activity
fix(naturaldelta): catch OverflowError for float('inf') (python-human…
Mukller commentedon Jul 29, 2026
Root cause confirmed: the guard around
int(value)only catchesValueErrorandTypeError, butint(float('inf'))raisesOverflowError.float('nan')is silently handled becauseint(nan)raisesValueError. Butint(float('inf'))raisesOverflowError, which propagates uncaught.Fix: add
OverflowErrorto the except clause:I have a PR ready.
test: regression for python-humanize#333 non-finite float OverflowErr…