[issue46018] expm1 may incorrectly raise OverflowError on underflow

2021-12-09 Thread miss-islington
miss-islington added the comment: New changeset ca08655b808aed2e3abeb64cb67d98a79a661dda by Miss Islington (bot) in branch '3.10': bpo-46018: Ensure that math.expm1 does not raise on underflow (GH-29997) https://github.com/python/cpython/commit/ca08655b808aed2e3abeb64cb67d98a79a661dda

[issue46018] expm1 may incorrectly raise OverflowError on underflow

2021-12-09 Thread Steve Dower
Change by Steve Dower : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___ ___

[issue46018] expm1 may incorrectly raise OverflowError on underflow

2021-12-09 Thread miss-islington
miss-islington added the comment: New changeset 5ae4265b8c8042c496e569b6dbf9ef107e1d5b31 by Miss Islington (bot) in branch '3.9': bpo-46018: Ensure that math.expm1 does not raise on underflow (GH-29997) https://github.com/python/cpython/commit/5ae4265b8c8042c496e569b6dbf9ef107e1d5b31

[issue46018] expm1 may incorrectly raise OverflowError on underflow

2021-12-09 Thread Steve Dower
Steve Dower added the comment: New changeset 3363e1cb05d0d19ed172ea63606d8cb6268747fc by Steve Dower in branch 'main': bpo-46018: Ensure that math.expm1 does not raise on underflow (GH-29997) https://github.com/python/cpython/commit/3363e1cb05d0d19ed172ea63606d8cb6268747fc --

[issue46018] expm1 may incorrectly raise OverflowError on underflow

2021-12-09 Thread miss-islington
Change by miss-islington : -- pull_requests: +28237 pull_request: https://github.com/python/cpython/pull/30013 ___ Python tracker ___

[issue46018] expm1 may incorrectly raise OverflowError on underflow

2021-12-09 Thread miss-islington
Change by miss-islington : -- nosy: +miss-islington, miss-islington nosy_count: 2.0 -> 3.0 pull_requests: +28234, 28235 pull_request: https://github.com/python/cpython/pull/30012 ___ Python tracker

[issue46018] expm1 may incorrectly raise OverflowError on underflow

2021-12-09 Thread miss-islington
Change by miss-islington : -- nosy: +miss-islington, miss-islington, miss-islington nosy_count: 2.0 -> 3.0 pull_requests: +28234, 28235, 28236 pull_request: https://github.com/python/cpython/pull/30012 ___ Python tracker

[issue46018] expm1 may incorrectly raise OverflowError on underflow

2021-12-09 Thread miss-islington
Change by miss-islington : -- nosy: +miss-islington nosy_count: 2.0 -> 3.0 pull_requests: +28234 pull_request: https://github.com/python/cpython/pull/30012 ___ Python tracker

[issue46018] expm1 may incorrectly raise OverflowError on underflow

2021-12-09 Thread Mark Dickinson
Mark Dickinson added the comment: > Lines 500-504 are the ones that trigger it. Ah, right. Thanks. > Apparently there are no tests in that file for straight exp() Yes - that file was mostly written to give good coverage for places where we'd written our own implementations rather than

[issue46018] expm1 may incorrectly raise OverflowError on underflow

2021-12-09 Thread Steve Dower
Steve Dower added the comment: Lines 500-504 are the ones that trigger it. Apparently there are no tests in that file for straight exp(), but the equivalent tests for those would return 0.0 and suppress ERANGE too. -- ___ Python tracker

[issue46018] expm1 may incorrectly raise OverflowError on underflow

2021-12-09 Thread Mark Dickinson
Mark Dickinson added the comment: > I've also got no idea how to write a test for this Yep, that's fine. All I want is that at least one particular value that caused the spurious OverflowError is in the test suite somewhere, but it sounds as though that's already the case. I'd imagine that

[issue46018] expm1 may incorrectly raise OverflowError on underflow

2021-12-09 Thread Steve Dower
Steve Dower added the comment: I've also got no idea how to write a test for this, given that it's a very thin wrapper around a platform's C runtime library. Our existing test discovered when the library changed behaviour to start setting errno, which is probably the best we can do.

[issue46018] expm1 may incorrectly raise OverflowError on underflow

2021-12-09 Thread Steve Dower
Steve Dower added the comment: I considered just switching to <2.0, but wasn't sure if I would be breaking some other unspoken behaviour there. But you're right, it's really just detecting underflow vs. overflow, so that's a much simpler way to check. I've filed the upstream report. I

[issue46018] expm1 may incorrectly raise OverflowError on underflow

2021-12-09 Thread Mark Dickinson
Mark Dickinson added the comment: I presume this is also worth an upstream report? Setting ERANGE on a result that's close to -1.0 is rather questionable. -- ___ Python tracker

[issue46018] expm1 may incorrectly raise OverflowError on underflow

2021-12-09 Thread Mark Dickinson
Mark Dickinson added the comment: It's a bit cheap and nasty, but I think we could simply replace the line: if (fabs(x) < 1.0) in is_error with if (fabs(x) < 2.0) perhaps with an explanatory comment. All we need to do is distinguish underflow from overflow, and 2.0 is still

[issue46018] expm1 may incorrectly raise OverflowError on underflow

2021-12-09 Thread Mark Dickinson
Change by Mark Dickinson : -- nosy: +mark.dickinson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46018] expm1 may incorrectly raise OverflowError on underflow

2021-12-08 Thread Steve Dower
Change by Steve Dower : -- keywords: +patch pull_requests: +28220 stage: -> patch review pull_request: https://github.com/python/cpython/pull/29997 ___ Python tracker ___

[issue46018] expm1 may incorrectly raise OverflowError on underflow

2021-12-08 Thread Steve Dower
New submission from Steve Dower : If a C runtime's math functions set errno to ERANGE, we assume it is a valid underflow if fabs(result) < 1.0. However, because expm1 includes a -1.0, it underflows towards -1.0. This fails the above check, and so if a runtime's expm1() sets ERANGE we will