]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #18513: Add workaround for OS X 10.8 cexp bug that leads to wrong cmath.rect...
authorRaymond Hettinger <python@rcn.com>
Sat, 20 Jul 2013 17:56:58 +0000 (10:56 -0700)
committerRaymond Hettinger <python@rcn.com>
Sat, 20 Jul 2013 17:56:58 +0000 (10:56 -0700)
Misc/NEWS
Modules/cmathmodule.c

index 5283da69c173cec0718ee6e94db16fce388d341d..87a4ec5ca24fe7a3d4dd9be07b5a372afd5b3368 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -28,6 +28,9 @@ Library
 
 - Issue #18455: multiprocessing should not retry connect() with same socket.
 
+- Issue #18513: Fix behaviour of cmath.rect w.r.t. signed zeros on OS X 10.8 +
+  gcc.
+
 - Issue #18101: Tcl.split() now process Unicode strings nested in a tuple as it
   do with byte strings.
 
index 0dc6bdb3968a411d9455557a7cf7ecd03bf1d184..57206785e71c439a3c4b6e632c969cebe30e02ad 100644 (file)
@@ -1006,6 +1006,13 @@ cmath_rect(PyObject *self, PyObject *args)
         else
             errno = 0;
     }
+    else if (phi == 0.0) {
+        /* Workaround for buggy results with phi=-0.0 on OS X 10.8.  See
+           bugs.python.org/issue18513. */
+        z.real = r;
+        z.imag = r * phi;
+        errno = 0;
+    }
     else {
         z.real = r * cos(phi);
         z.imag = r * sin(phi);