classification
Title: decimal module exception args incorrect for c module
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: decimal C module's exceptions don't match the Python version
View: 26208
Assigned To: Nosy List: joshringer, skrah
Priority: normal Keywords:

Created on 2017-12-07 03:54 by joshringer, last changed 2017-12-07 09:45 by skrah. This issue is now closed.

Messages (2)
msg307788 - (view) Author: Joshua Ringer (joshringer) Date: 2017-12-07 03:54
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'>]
msg307794 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2017-12-07 09:45
This is known and was deliberate when I wrote the module. The list contains conditions that trigger the exception.
History
Date User Action Args
2017-12-07 09:45:41skrahsetstatus: open -> closed
superseder: decimal C module's exceptions don't match the Python version
messages: + msg307794

resolution: duplicate
stage: resolved
2017-12-07 08:13:53serhiy.storchakasetnosy: + skrah
2017-12-07 03:54:39joshringercreate