summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorStefan Krah <skrah@bytereef.org>2012-09-10 17:34:58 (GMT)
committerStefan Krah <skrah@bytereef.org>2012-09-10 17:34:58 (GMT)
commitdbcf103be09b63531451166e4f53e8f9a6dd852e (patch)
treedf96aae09921cc923ebffd9f9d2a957784c09819 /Lib/test
parent6c4b09533464e3337623e0b2abc990500898c0b8 (diff)
downloadcpython-dbcf103be09b63531451166e4f53e8f9a6dd852e.zip
cpython-dbcf103be09b63531451166e4f53e8f9a6dd852e.tar.gz
cpython-dbcf103be09b63531451166e4f53e8f9a6dd852e.tar.bz2
Issue #15882: Change _decimal to accept any coefficient tuple when
constructing infinities. This is done for backwards compatibility with decimal.py: Infinity coefficients are undefined in _decimal (in accordance with the specification).
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_decimal.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index d00ed5a..3ca5927 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -1992,7 +1992,8 @@ class UsabilityTest(unittest.TestCase):
d = Decimal("-4.34913534E-17")
self.assertEqual(d.as_tuple(), (1, (4, 3, 4, 9, 1, 3, 5, 3, 4), -25) )
- # XXX non-compliant infinity payload.
+ # The '0' coefficient is implementation specific to decimal.py.
+ # It has no meaning in the C-version and is ignored there.
d = Decimal("Infinity")
self.assertEqual(d.as_tuple(), (0, (0,), 'F') )
@@ -2012,12 +2013,14 @@ class UsabilityTest(unittest.TestCase):
d = Decimal( (1, (), 'n') )
self.assertEqual(d.as_tuple(), (1, (), 'n') )
- # XXX coefficient in infinity should raise an error
- if self.decimal == P:
- d = Decimal( (0, (4, 5, 3, 4), 'F') )
- self.assertEqual(d.as_tuple(), (0, (0,), 'F'))
- d = Decimal( (1, (0, 2, 7, 1), 'F') )
- self.assertEqual(d.as_tuple(), (1, (0,), 'F'))
+ # For infinities, decimal.py has always silently accepted any
+ # coefficient tuple.
+ d = Decimal( (0, (0,), 'F') )
+ self.assertEqual(d.as_tuple(), (0, (0,), 'F'))
+ d = Decimal( (0, (4, 5, 3, 4), 'F') )
+ self.assertEqual(d.as_tuple(), (0, (0,), 'F'))
+ d = Decimal( (1, (0, 2, 7, 1), 'F') )
+ self.assertEqual(d.as_tuple(), (1, (0,), 'F'))
def test_subclassing(self):
# Different behaviours when subclassing Decimal