Commit fe0bf42
committed
fix(naturaldelta): catch OverflowError for float('inf') (#333)
`int(float("inf"))` raises `OverflowError`, not `ValueError`, so the
existing `except (ValueError, TypeError)` guard misses it. The function
docstring states that non-finite floats are returned unchanged, but
`float("inf")` and `float("-inf")` raised uncaught `OverflowError`
while only `float("nan")` was silently returned.
Add `OverflowError` to the except clause so that ±inf are treated the
same as nan. Remove the misleading "Raises: OverflowError" note from
the docstring since that exception is now caught.1 parent 42b4a1d commit fe0bf42
1 file changed
Lines changed: 1 addition & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | 120 | | |
124 | 121 | | |
125 | 122 | | |
| |||
151 | 148 | | |
152 | 149 | | |
153 | 150 | | |
154 | | - | |
| 151 | + | |
155 | 152 | | |
156 | 153 | | |
157 | 154 | | |
| |||
0 commit comments