classification
Title: cmath.polar() can raise due to pre-existing errno
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.6, Python 3.5, Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: mark.dickinson, pitrou, python-dev, vstinner
Priority: normal Keywords: patch

Created on 2015-06-23 12:15 by pitrou, last changed 2015-06-23 12:44 by pitrou. This issue is now closed.

Files
File name Uploaded Description Edit
polar_errno.patch pitrou, 2015-06-23 12:15
Messages (7)
msg245678 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2015-06-23 12:15
Here is a patch, with additional tests.
msg245679 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-06-23 12:26
polar_errno.patch doesn't apply cleanly on the default branch, I get that you wrote your patch for Python 3.4.

+    @cpython_only
+    def test_polar_errno(self):
+        # Check a previously set C errno doesn't disturb polar()

Please add the number of this issue in the comment.

+        inf = float('inf')
+ ...
+        nan = float('nan')

On Python 3.5 and 3.6, You can use math.inf and math.nan.

Except of that, the patch looks good to me.
msg245681 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2015-06-23 12:27
> On Python 3.5 and 3.6, You can use math.inf and math.nan.

The patch is for 3.4.
msg245682 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-06-23 12:28
>> On Python 3.5 and 3.6, You can use math.inf and math.nan.
>
> The patch is for 3.4.

Ok, it confirms my guess. But when you merge your change into 3.5, you may replace nan and inf with math.nan and math.inf. As you want.
msg245683 - (view) Author: Roundup Robot (python-dev) Date: 2015-06-23 12:40
New changeset 70e3230c2872 by Antoine Pitrou in branch '3.4':
Issue #24489: ensure a previously set C errno doesn't disturb cmath.polar().
https://hg.python.org/cpython/rev/70e3230c2872

New changeset d165712b2dee by Antoine Pitrou in branch '3.5':
Issue #24489: ensure a previously set C errno doesn't disturb cmath.polar().
https://hg.python.org/cpython/rev/d165712b2dee

New changeset b1fac7685947 by Antoine Pitrou in branch 'default':
Issue #24489: ensure a previously set C errno doesn't disturb cmath.polar().
https://hg.python.org/cpython/rev/b1fac7685947
msg245684 - (view) Author: Roundup Robot (python-dev) Date: 2015-06-23 12:44
New changeset 9f4b066754c3 by Antoine Pitrou in branch '2.7':
Issue #24489: ensure a previously set C errno doesn't disturb cmath.polar().
https://hg.python.org/cpython/rev/9f4b066754c3
msg245685 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2015-06-23 12:44
Ok, pushed it!
History
Date User Action Args
2015-06-23 12:44:49pitrousetstatus: open -> closed
resolution: fixed
messages: + msg245685

stage: patch review -> resolved
2015-06-23 12:44:27python-devsetmessages: + msg245684
2015-06-23 12:40:14python-devsetnosy: + python-dev
messages: + msg245683
2015-06-23 12:28:55vstinnersetmessages: + msg245682
2015-06-23 12:27:04pitrousetmessages: + msg245681
2015-06-23 12:26:04vstinnersetnosy: + vstinner
messages: + msg245679
2015-06-23 12:15:08pitroucreate