summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_math.py
diff options
context:
space:
mode:
authorMark Dickinson <mdickinson@enthought.com>2021-06-12 09:23:02 (GMT)
committerGitHub <noreply@github.com>2021-06-12 09:23:02 (GMT)
commit4a42cebf6dd769e2fa4e234a9e91093b3ad1cb63 (patch)
tree925efc812b8810d8c5fb6c1040307d1cacf4b976 /Lib/test/test_math.py
parent3ec3ee7d2e9b45b586e486e429b412d6d0ca530f (diff)
downloadcpython-4a42cebf6dd769e2fa4e234a9e91093b3ad1cb63.zip
cpython-4a42cebf6dd769e2fa4e234a9e91093b3ad1cb63.tar.gz
cpython-4a42cebf6dd769e2fa4e234a9e91093b3ad1cb63.tar.bz2
bpo-44339: Fix math.pow corner case to comply with IEEE 754 (GH-26606)
Change the behaviour of `math.pow(0.0, -math.inf)` and `math.pow(-0.0, -math.inf)` to return positive infinity instead of raising `ValueError`. This makes `math.pow` consistent with the built-in `pow` (and the `**` operator) for this particular special case, and brings the `math.pow` special-case handling into compliance with IEEE 754.
Diffstat (limited to 'Lib/test/test_math.py')
-rw-r--r--Lib/test/test_math.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py
index da16284..42b61c3 100644
--- a/Lib/test/test_math.py
+++ b/Lib/test/test_math.py
@@ -1230,7 +1230,7 @@ class MathTests(unittest.TestCase):
self.assertRaises(ValueError, math.pow, 0., -2.)
self.assertRaises(ValueError, math.pow, 0., -2.3)
self.assertRaises(ValueError, math.pow, 0., -3.)
- self.assertRaises(ValueError, math.pow, 0., NINF)
+ self.assertEqual(math.pow(0., NINF), INF)
self.assertTrue(math.isnan(math.pow(0., NAN)))
# pow(INF, x)
@@ -1256,7 +1256,7 @@ class MathTests(unittest.TestCase):
self.assertRaises(ValueError, math.pow, -0., -2.)
self.assertRaises(ValueError, math.pow, -0., -2.3)
self.assertRaises(ValueError, math.pow, -0., -3.)
- self.assertRaises(ValueError, math.pow, -0., NINF)
+ self.assertEqual(math.pow(-0., NINF), INF)
self.assertTrue(math.isnan(math.pow(-0., NAN)))
# pow(NINF, x)