[Python-checkins] cpython (3.3): Issue #18513: Add workaround for OS X 10.8 cexp bug that leads to wrong

mark.dickinson python-checkins at python.org
Sat Jul 20 19:00:28 CEST 2013


http://hg.python.org/cpython/rev/ce771c2d0220
changeset:   84736:ce771c2d0220
branch:      3.3
parent:      84734:76bb3fe6ce8f
user:        Mark Dickinson <dickinsm at gmail.com>
date:        Sat Jul 20 17:59:13 2013 +0100
summary:
  Issue #18513: Add workaround for OS X 10.8 cexp bug that leads to wrong cmath.rect(0.0,-0.0) results.

files:
  Misc/NEWS             |  3 +++
  Modules/cmathmodule.c |  7 +++++++
  2 files changed, 10 insertions(+), 0 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -49,6 +49,9 @@
 Library
 -------
 
+- Issue #18513: Fix behaviour of cmath.rect w.r.t. signed zeros on OS X 10.8 +
+  gcc.
+
 - Issue #18480: Add missing call to PyType_Ready to the _elementtree extension.
 
 - Issue #17778: Fix test discovery for test_multiprocessing. (Patch by
diff --git a/Modules/cmathmodule.c b/Modules/cmathmodule.c
--- a/Modules/cmathmodule.c
+++ b/Modules/cmathmodule.c
@@ -1006,6 +1006,13 @@
         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);

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list