From: Mark Dickinson Date: Sat, 20 Jul 2013 16:59:13 +0000 (+0100) Subject: Issue #18513: Add workaround for OS X 10.8 cexp bug that leads to wrong cmath.rect... X-Git-Tag: v3.4.0a1~131^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=58ceecfe5ac0ad436d556b589870dd2df62731c0;p=python Issue #18513: Add workaround for OS X 10.8 cexp bug that leads to wrong cmath.rect(0.0,-0.0) results. --- diff --git a/Misc/NEWS b/Misc/NEWS index de16f7b1de..f79f62584a 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -49,6 +49,9 @@ Core and Builtins 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 index 3021cf0466..36bf4a1e3d 100644 --- a/Modules/cmathmodule.c +++ b/Modules/cmathmodule.c @@ -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);