Index: Modules/mathmodule.c =================================================================== --- Modules/mathmodule.c (revision 85031) +++ Modules/mathmodule.c (working copy) @@ -1572,12 +1572,12 @@ "math domain error"); return NULL; } - /* Special case for log(1), to make sure we get an - exact result there. */ - if (e == 1 && x == 0.5) - return PyFloat_FromDouble(0.0); - /* Value is ~= x * 2**e, so the log ~= log(x) + log(2) * e. */ - x = func(x) + func(2.0) * e; + if (x != 0.5) + /* Value is ~= x * 2**e, so the log ~= log(x) + log(2) * e. */ + x = func(x) + func(2.0) * e; + else + /* Special case for 0.5 * 2**e, to get better precision */ + x = func(2.0) * (e - 1); return PyFloat_FromDouble(x); }