[New-bugs-announce] [issue15882] _decimal.Decimal constructed from tuple

Aaron report at bugs.python.org
Sat Sep 8 00:47:55 CEST 2012

New submission from Aaron:

I think I may have found a problem with the code that constructs Infinity from tuples in the C _decimal module.

# pure python (3.x or 2.x)
>>> decimal.Decimal( (0, (0, ), 'F'))

# _decimal
>>> decimal.Decimal( (0, (0, ), 'F'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
decimal.InvalidOperation: [<class 'decimal.ConversionSyntax'>]

Also, there is no unit test coverage for constructing these special values from tuples either.  I have provided some that pass with the existing pure python code and with the modifications to the _decimal C code.

The unit tests can be applied to Python 2.7.x as well, if desired.  They would go in the ExplicitConstructionTest.test_explicit_from_tuples() method.

components: Extension Modules
files: _decimal.diff
keywords: patch
messages: 170017
nosy: hac.man
priority: normal
severity: normal
status: open
title: _decimal.Decimal constructed from tuple
versions: Python 3.3
Added file: http://bugs.python.org/file27144/_decimal.diff

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list