This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: math.degrees(sys.float_info.max) should throw an OverflowError exception
Type: enhancement Stage: resolved
Components: Versions: Python 3.11
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: anthonypjshaw, franciscouzo, mark.dickinson, rhettinger
Priority: normal Keywords: easy

Created on 2016-10-26 21:25 by franciscouzo, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
math-degrees-overflow.diff mark.dickinson, 2016-10-27 17:47 review
Messages (8)
msg279513 - (view) Author: Francisco Couzo (franciscouzo) * Date: 2016-10-26 21:25
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
msg279535 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2016-10-27 11:52
I agree in principle.

On one hand, it's difficult to care too much, since `math.degrees` is going to be all-but-useless for inputs larger than `1e20` or so anyway (the actual angle represented is getting lost in floating-point noise by that point).

OTOH, *because* of the above, at least making the change shouldn't break any code that wasn't broken already.
msg279536 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2016-10-27 12:26
Francisco: would you be interested in writing a patch?
msg279555 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2016-10-27 17:47
Actually, here's a patch.
msg341588 - (view) Author: anthony shaw (anthonypjshaw) * (Python triager) Date: 2019-05-06 18:29
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.
msg416798 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2022-04-05 18:35
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.
msg416799 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2022-04-05 18:41
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
msg416806 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2022-04-05 19:14
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).
History
Date User Action Args
2022-04-11 14:58:38adminsetgithub: 72726
2022-04-05 19:14:16mark.dickinsonsetmessages: + msg416806
2022-04-05 18:41:25rhettingersetassignee: rhettinger
2022-04-05 18:41:17rhettingersetmessages: + msg416799
2022-04-05 18:35:17rhettingersetstatus: open -> closed
resolution: wont fix
messages: + msg416798

stage: resolved
2022-04-05 18:20:56iritkatrielsetkeywords: + easy, - patch
type: enhancement
versions: + Python 3.11
2019-05-06 18:29:54anthonypjshawsetnosy: + rhettinger, anthonypjshaw
messages: + msg341588
2016-10-27 17:47:27mark.dickinsonsetfiles: + math-degrees-overflow.diff
keywords: + patch
messages: + msg279555
2016-10-27 12:26:29mark.dickinsonsetmessages: + msg279536
2016-10-27 11:52:22mark.dickinsonsetnosy: + mark.dickinson
messages: + msg279535
2016-10-26 21:25:41franciscouzocreate