[issue21227] Decimal class error messages for integer division aren't good
Stefan Krah
report at bugs.python.org
Wed Apr 16 22:28:42 CEST 2014
Stefan Krah added the comment:
Raymond Hettinger <report at bugs.python.org> wrote:
> > It is certainly possible to document DivisionImpossible etc.
>
> This should not be done. We've made strong efforts to not extend the Decimal Arithmetic Specification.
The exceptions are already there:
Python 2.7.3 (default, Mar 13 2014, 11:03:55)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import decimal
>>> print(decimal.DivisionImpossible.__doc__)
Cannot perform the division adequately.
This occurs and signals invalid-operation if the integer result of a
divide-integer or remainder operation had too many digits (would be
longer than precision). The result is [0,qNaN].
The specification distinguishes between "conditions" and "signals". It is
true that the conditions are not technically raised, but they are very
much "subclasses" of InvalidOperation.
Cowlishaw himself makes the distinction between InvalidOperation
and IEEEInvalidOperation. The latter groups all conditions together:
#define DEC_IEEE_754_Invalid_operation (DEC_Conversion_syntax | \
DEC_Division_impossible | \
DEC_Division_undefined | \
DEC_Insufficient_storage | \
DEC_Invalid_context | \
DEC_Invalid_operation)
So while I don't particularly care whether we document the conditions or
not, I don't think doing so would extend the specification.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21227>
_______________________________________
More information about the Python-bugs-list
mailing list