[issue26208] decimal C module's exceptions don't match the Python version

Pekka Klärck report at bugs.python.org
Thu Sep 6 03:29:10 EDT 2018


Pekka Klärck <pekka.klarck at gmail.com> added the comment:

Just noticed this myself when testing with Python 3.5-3.7:

    >>> from decimal import Decimal
    >>> d = Decimal('foo')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    decimal.InvalidOperation: [<class 'decimal.ConversionSyntax'>]


With Python 2.7 I get this error instead:

    decimal.InvalidOperation: Invalid literal for Decimal: 'foo'


I'm writing type conversion code and was planning to include the error message by Python along with some higher level explanation when reporting errors. `[<class 'decimal.ConversionSyntax'>]` would be such a strange message that I need to make a special case with decimal.

----------
nosy: +pekka.klarck

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


More information about the Python-bugs-list mailing list