[3.14] gh-132876: workaround broken ldexp() on Windows 10 (GH-133135) (#134684)

gh-132876: workaround broken ldexp() on Windows 10 (GH-133135)

* gh-132876: workaround broken ldexp() on Windows 10

ldexp() fails to round subnormal results before Windows 11,
so hide their bug.
(cherry picked from commit cf8941c603)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Tim Peters <tim.peters@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-05-26 05:23:45 +02:00 committed by GitHub
parent 7216f7b59c
commit 16187b58bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 31 additions and 0 deletions

View file

@ -1214,6 +1214,12 @@ class MathTests(unittest.TestCase):
self.assertEqual(math.ldexp(NINF, n), NINF)
self.assertTrue(math.isnan(math.ldexp(NAN, n)))
@requires_IEEE_754
def testLdexp_denormal(self):
# Denormal output incorrectly rounded (truncated)
# on some Windows.
self.assertEqual(math.ldexp(6993274598585239, -1126), 1e-323)
def testLog(self):
self.assertRaises(TypeError, math.log)
self.assertRaises(TypeError, math.log, 1, 2, 3)