Message258965
Exceptions from the decimal module are quite unfriendly:
>>> Decimal(42) / Decimal(0)
...
decimal.DivisionByZero: [<class 'decimal.DivisionByZero'>]
>>> huge = Decimal('9' * 99)
>>> huge.quantize(Decimal('0.1'))
...
decimal.InvalidOperation: [<class 'decimal.InvalidOperation'>]
compared to the pure Python implementation:
decimal.DivisionByZero: x / 0
decimal.InvalidOperation: quantize result has too many digits for current context
If I'm reading http://bugs.python.org/issue21227 right, the exception argument is a of signals, and indicates the complete set of signals raised by the operation. However, this is (AFAICS) not documented, and not portable (since it's not present in the Python version).
I believe this behavior should be
- either dropped in favor of friendlier error messages (or possibly moved to a more internal attribute of the exception, and documented as an optional CPython feature),
- or documented, and implemented in _pydecimal as well.
Which of those actions would be right seems to be a question of whether the exception argument is part of the API. |
|
Date |
User |
Action |
Args |
2016-01-26 17:46:59 | petr.viktorin | set | recipients:
+ petr.viktorin, skrah |
2016-01-26 17:46:59 | petr.viktorin | set | messageid: <1453830419.58.0.782557332566.issue26208@psf.upfronthosting.co.za> |
2016-01-26 17:46:59 | petr.viktorin | link | issue26208 messages |
2016-01-26 17:46:59 | petr.viktorin | create | |
|