New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
math.degrees(sys.float_info.max) should throw an OverflowError exception #72726
Comments
Most functions in the math library raise an OverflowError when the arguments are finite but the result is not. >>> math.exp(sys.float_info.max)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: math range error
>>> math.degrees(sys.float_info.max)
inf |
I agree in principle. On one hand, it's difficult to care too much, since OTOH, *because* of the above, at least making the change shouldn't break any code that wasn't broken already. |
Francisco: would you be interested in writing a patch? |
Actually, here's a patch. |
Francisco, I recommend converting the patch into a GitHub pull request to make it easier to code review. Mark, Raymond, please could you re-review this patch. |
I'm not interested in having this move forward. AFAICT it doesn't solve any known user problems (no one has cared about this before or since this issue was opened). It slightly slows the code. And it might break some existing code that wasn't previously a need to catch an OverflowError. Marking this as closed. If someone thinks this is really needed, feel free to reopen. |
One other thought. The mental model for degrees() is just a simple scaling operation. If done in pure Python, we would get *inf* rather than an OverflowError. I don't see any value in breaking with the obvious substitution: >>> sys.float_info.max * (180 / pi)
inf |
FWIW, I do consider this a bug, albeit a minor one. I may find time to fix it at some point (but it's fine to leave it closed until that time comes). |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: