diff -r 12c062dbe746 Lib/test/cmath_testcases.txt --- a/Lib/test/cmath_testcases.txt Thu Aug 16 22:18:37 2012 +0200 +++ b/Lib/test/cmath_testcases.txt Fri Aug 17 15:37:11 2012 -0400 @@ -849,7 +849,6 @@ atan0304 atan -9.9998886718268301e-321 -1.0 -> -0.78539816339744828 -368.76019403576692 -- special values -atan1000 atan -0.0 0.0 -> -0.0 0.0 atan1001 atan nan 0.0 -> nan 0.0 atan1002 atan -0.0 1.0 -> -0.0 inf divide-by-zero atan1003 atan -inf 0.0 -> -1.5707963267948966 0.0 @@ -863,7 +862,6 @@ atan1011 atan -2.2999999999999998 nan -> nan nan atan1012 atan -inf nan -> -1.5707963267948966 0.0 ignore-imag-sign atan1013 atan nan nan -> nan nan -atan1014 atan 0.0 0.0 -> 0.0 0.0 atan1015 atan 0.0 1.0 -> 0.0 inf divide-by-zero atan1016 atan inf 0.0 -> 1.5707963267948966 0.0 atan1017 atan inf 2.2999999999999998 -> 1.5707963267948966 0.0 @@ -873,7 +871,6 @@ atan1021 atan 0.0 nan -> nan nan atan1022 atan 2.2999999999999998 nan -> nan nan atan1023 atan inf nan -> 1.5707963267948966 0.0 ignore-imag-sign -atan1024 atan 0.0 -0.0 -> 0.0 -0.0 atan1025 atan nan -0.0 -> nan -0.0 atan1026 atan 0.0 -1.0 -> 0.0 -inf divide-by-zero atan1027 atan inf -0.0 -> 1.5707963267948966 -0.0 @@ -883,7 +880,6 @@ atan1031 atan 2.2999999999999998 -inf -> 1.5707963267948966 -0.0 atan1032 atan inf -inf -> 1.5707963267948966 -0.0 atan1033 atan nan -inf -> nan -0.0 -atan1034 atan -0.0 -0.0 -> -0.0 -0.0 atan1035 atan -0.0 -1.0 -> -0.0 -inf divide-by-zero atan1036 atan -inf -0.0 -> -1.5707963267948966 -0.0 atan1037 atan -inf -2.2999999999999998 -> -1.5707963267948966 -0.0 @@ -1011,9 +1007,7 @@ atanh0222 atanh -5.9656816081325078e-317 9.9692253555416263e-313 -> -5.9656816081325078e-317 9.9692253555416263e-313 atanh0223 atanh -6.5606671178400239e-313 -2.1680936406357335e-309 -> -6.5606671178400239e-313 -2.1680936406357335e-309 atanh0224 atanh 0.0 2.5230944401820779e-319 -> 0.0 2.5230944401820779e-319 -atanh0225 atanh -0.0 5.6066569490064658e-320 -> -0.0 5.6066569490064658e-320 atanh0226 atanh 0.0 -2.4222487249468377e-317 -> 0.0 -2.4222487249468377e-317 -atanh0227 atanh -0.0 -3.0861101089206037e-316 -> -0.0 -3.0861101089206037e-316 atanh0228 atanh 3.1219222884393986e-310 0.0 -> 3.1219222884393986e-310 0.0 atanh0229 atanh 9.8926337564976196e-309 -0.0 -> 9.8926337564976196e-309 -0.0 atanh0230 atanh -1.5462535092918154e-312 0.0 -> -1.5462535092918154e-312 0.0 @@ -1051,7 +1045,6 @@ atanh1021 atanh nan -0.0 -> nan nan atanh1022 atanh nan -2.3 -> nan nan atanh1023 atanh nan -inf -> 0.0 -1.5707963267948966 ignore-real-sign -atanh1024 atanh -0.0 -0.0 -> -0.0 -0.0 atanh1025 atanh -0.0 nan -> -0.0 nan atanh1026 atanh -1.0 -0.0 -> -inf -0.0 divide-by-zero atanh1027 atanh -0.0 -inf -> -0.0 -1.5707963267948966 @@ -1061,7 +1054,6 @@ atanh1031 atanh -inf -2.3 -> -0.0 -1.5707963267948966 atanh1032 atanh -inf -inf -> -0.0 -1.5707963267948966 atanh1033 atanh -inf nan -> -0.0 nan -atanh1034 atanh -0.0 0.0 -> -0.0 0.0 atanh1035 atanh -1.0 0.0 -> -inf 0.0 divide-by-zero atanh1036 atanh -0.0 inf -> -0.0 1.5707963267948966 atanh1037 atanh -2.3 inf -> -0.0 1.5707963267948966 diff -r 12c062dbe746 Lib/test/test_cmath.py --- a/Lib/test/test_cmath.py Thu Aug 16 22:18:37 2012 +0200 +++ b/Lib/test/test_cmath.py Fri Aug 17 15:37:11 2012 -0400 @@ -532,6 +532,36 @@ for z in complex_zeros: self.assertComplexIdentical(cmath.atanh(z), z) + @requires_IEEE_754 + @unittest.skipIf(sysconfig.get_config_var('LOG1P_DROPS_ZERO_SIGN'), + "system log1p() function doesn't preserve the sign") + def testAtanhSignNearZero(self): + for z in (-30861101e-316, 5.6067e-320): + expected = complex(-0.0, z) + actual = cmath.atanh(complex(-0.0, z)) + error_message = ( + 'Expected: complex({!r}, {!r})\n' + 'Received: complex({!r}, {!r})\n' + 'Received value insufficiently close to expected value.' + ).format( + expected.real, + expected.imag, + actual.real, + actual.imag + ) + + self.rAssertAlmostEqual( + expected.real, + actual.real, + abs_err=5e-323, + msg=error_message, + ) + + self.rAssertAlmostEqual( + expected.imag, + actual.imag, + msg=error_message, + ) def test_main(): run_unittest(CMathTests)