[New-bugs-announce] [issue32239] decimal module exception args incorrect for c module

Joshua Ringer report at bugs.python.org
Wed Dec 6 22:54:39 EST 2017


New submission from Joshua Ringer <i.atent.dead at gmail.com>:

Exception instance args for decimal errors are supposed to be a descriptive string. However, in the c module, they are currently a list of one containing the underlying exception class. The pure python module is correct.

See the following interpreter output for further detail:

Python 3.6.3 (default, Oct  4 2017, 06:09:15)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from _pydecimal import Decimal
>>> Decimal('badstring')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/_pydecimal.py", line 597, in __new__
    "Invalid literal for Decimal: %r" % value)
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/_pydecimal.py", line 4081, in _raise_error
    raise error(explanation)
decimal.InvalidOperation: Invalid literal for Decimal: 'badstring'
>>> from _decimal import Decimal
>>> Decimal('badstring')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
decimal.InvalidOperation: [<class 'decimal.ConversionSyntax'>]

----------
components: Library (Lib)
messages: 307788
nosy: joshringer
priority: normal
severity: normal
status: open
title: decimal module exception args incorrect for c module
type: behavior
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32239>
_______________________________________


More information about the New-bugs-announce mailing list