[New-bugs-announce] [issue7684] decimal.py: infinity coefficients in tuples

Stefan Krah report at bugs.python.org
Tue Jan 12 21:18:37 CET 2010


New submission from Stefan Krah <stefan-usenet at bytereef.org>:

It should not be possible to pass coefficients when constructing infinities from tuples. Otherwise it looks like infinities can have payloads (which they can't).

Example:

>>> import decimal, cdecimal
>>> d = decimal.Decimal((0, (4, 5, 3, 4), 'F'))
>>> d
Decimal('Infinity')

>>> d = cdecimal.Decimal((0, (4, 5, 3, 4), 'F'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cdecimal.InvalidOperation: [<class 'cdecimal.ConversionSyntax'>]


Also, the non-coefficient of infinities should preferably be represented as an empty tuple:

>>> decimal.Decimal("Infinity").as_tuple()
DecimalTuple(sign=0, digits=(0,), exponent='F')
>>> cdecimal.Decimal("Infinity").as_tuple()
(0, (), 'F')

----------
components: Library (Lib)
messages: 97656
nosy: mark.dickinson, skrah
severity: normal
status: open
title: decimal.py: infinity coefficients in tuples
type: behavior
versions: Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7684>
_______________________________________


More information about the New-bugs-announce mailing list