Commit ffdc079
Zo Bot
naturaldelta: include OverflowError in the int() guard so float('inf') returns unchanged
The docstring says naturaldelta returns non-number input unchanged. int(float('inf')) raises OverflowError (not ValueError or TypeError), so the existing except (ValueError, TypeError) clause let it escape.
The two new test cases (float('inf') and float('-inf')) fail on the pre-fix code with OverflowError and pass once OverflowError is added to the except tuple. The existing 'NaN' string case still returns "NaN" because str('NaN') is 'NaN' and float('NaN') → nan → int(nan) still raises ValueError which is still caught.1 parent 9326b16 commit ffdc079
2 files changed
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | | - | |
| 154 | + | |
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
| 132 | + | |
| 133 | + | |
131 | 134 | | |
132 | 135 | | |
133 | 136 | | |
134 | 137 | | |
135 | 138 | | |
136 | 139 | | |
137 | 140 | | |
138 | | - | |
| 141 | + | |
| 142 | + | |
139 | 143 | | |
140 | 144 | | |
141 | 145 | | |
| |||
0 commit comments