summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2017-09-12 06:08:49 (GMT)
committerGitHub <noreply@github.com>2017-09-12 06:08:49 (GMT)
commitcb356c2ecc0528d47fee2b9f4b32da4fcfb48b3a (patch)
treeae90d2a83114d93250692df87b5c811488e8e1a7 /Lib/test
parent99b941b420d63027654dc6722f1648a8f36d2925 (diff)
downloadcpython-cb356c2ecc0528d47fee2b9f4b32da4fcfb48b3a.zip
cpython-cb356c2ecc0528d47fee2b9f4b32da4fcfb48b3a.tar.gz
cpython-cb356c2ecc0528d47fee2b9f4b32da4fcfb48b3a.tar.bz2
[3.6] bpo-31373: remove overly strict float range checks (GH-3486) (#3495)
This undoes a853a8ba7850381d49b284295dd6f0dc491dbe44 except for the pytime.c parts. We want to continue to allow IEEE 754 doubles larger than FLT_MAX to be rounded into finite floats. Tests were added to very this behavior. (cherry picked from commit 2bb69a5b4e7f96cb35d1b28aa7b7b3974b351f59)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_float.py6
-rw-r--r--Lib/test/test_getargs2.py6
2 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py
index 6491f45..c5ca50c 100644
--- a/Lib/test/test_float.py
+++ b/Lib/test/test_float.py
@@ -613,6 +613,12 @@ class IEEEFormatTestCase(unittest.TestCase):
('<f', LE_FLOAT_NAN)]:
struct.unpack(fmt, data)
+ @support.requires_IEEE_754
+ def test_serialized_float_rounding(self):
+ from _testcapi import FLT_MAX
+ self.assertEqual(struct.pack("<f", 3.40282356e38), struct.pack("<f", FLT_MAX))
+ self.assertEqual(struct.pack("<f", -3.40282356e38), struct.pack("<f", -FLT_MAX))
+
class FormatTestCase(unittest.TestCase):
def test_format(self):
diff --git a/Lib/test/test_getargs2.py b/Lib/test/test_getargs2.py
index 8a194aa..d14a6ee 100644
--- a/Lib/test/test_getargs2.py
+++ b/Lib/test/test_getargs2.py
@@ -377,6 +377,12 @@ class Float_TestCase(unittest.TestCase):
r = getargs_f(NAN)
self.assertNotEqual(r, r)
+ @support.requires_IEEE_754
+ def test_f_rounding(self):
+ from _testcapi import getargs_f
+ self.assertEqual(getargs_f(3.40282356e38), FLT_MAX)
+ self.assertEqual(getargs_f(-3.40282356e38), -FLT_MAX)
+
def test_d(self):
from _testcapi import getargs_d
self.assertEqual(getargs_d(4.25), 4.25)