Skip to content
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

Closed
franciscouzo mannequin opened this issue Oct 26, 2016 · 8 comments
Closed

math.degrees(sys.float_info.max) should throw an OverflowError exception #72726

franciscouzo mannequin opened this issue Oct 26, 2016 · 8 comments
Assignees
Labels
3.11 only security fixes easy type-feature A feature request or enhancement

Comments

@franciscouzo
Copy link
Mannequin

franciscouzo mannequin commented Oct 26, 2016

BPO 28540
Nosy @rhettinger, @mdickinson, @franciscouzo, @tonybaloney
Files
  • math-degrees-overflow.diff
  • 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:

    assignee = 'https://github.com/rhettinger'
    closed_at = <Date 2022-04-05.18:35:17.801>
    created_at = <Date 2016-10-26.21:25:41.768>
    labels = ['easy', 'type-feature', '3.11']
    title = 'math.degrees(sys.float_info.max) should throw an OverflowError exception'
    updated_at = <Date 2022-04-05.19:14:16.911>
    user = 'https://github.com/franciscouzo'

    bugs.python.org fields:

    activity = <Date 2022-04-05.19:14:16.911>
    actor = 'mark.dickinson'
    assignee = 'rhettinger'
    closed = True
    closed_date = <Date 2022-04-05.18:35:17.801>
    closer = 'rhettinger'
    components = []
    creation = <Date 2016-10-26.21:25:41.768>
    creator = 'franciscouzo'
    dependencies = []
    files = ['45244']
    hgrepos = []
    issue_num = 28540
    keywords = ['easy']
    message_count = 8.0
    messages = ['279513', '279535', '279536', '279555', '341588', '416798', '416799', '416806']
    nosy_count = 4.0
    nosy_names = ['rhettinger', 'mark.dickinson', 'franciscouzo', 'anthonypjshaw']
    pr_nums = []
    priority = 'normal'
    resolution = 'wont fix'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue28540'
    versions = ['Python 3.11']

    @franciscouzo
    Copy link
    Mannequin Author

    franciscouzo mannequin commented Oct 26, 2016

    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

    @mdickinson
    Copy link
    Member

    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.

    @mdickinson
    Copy link
    Member

    Francisco: would you be interested in writing a patch?

    @mdickinson
    Copy link
    Member

    Actually, here's a patch.

    @tonybaloney
    Copy link
    Mannequin

    tonybaloney mannequin commented May 6, 2019

    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.

    @iritkatriel iritkatriel added easy 3.11 only security fixes type-feature A feature request or enhancement labels Apr 5, 2022
    @rhettinger
    Copy link
    Contributor

    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.

    @rhettinger
    Copy link
    Contributor

    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

    @rhettinger rhettinger self-assigned this Apr 5, 2022
    @mdickinson
    Copy link
    Member

    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).

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes easy type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants