[issue7046] decimal.py: use DivisionImpossible and DivisionUndefined
Mark Dickinson
report at bugs.python.org
Sat Nov 28 16:36:20 CET 2009
Mark Dickinson <dickinsm at gmail.com> added the comment:
I think it's actually easier for the user if we keep the exception type
as it is, so that it's clear which flag it corresponds to. This didn't
occur to me until I looked at the section of the doctests (around line
100 in decimal.py) that looks like:
>>> print c.divide(Decimal(0), Decimal(0))
Traceback (most recent call last):
...
...
...
InvalidOperation: 0 / 0
>>> print c.flags[InvalidOperation]
1
If the traceback specified 'DivisionUndefined' instead then the user has
to figure out that the corresponding flag/trap is InvalidOperation.
Of course this could be worked around by giving a more detailed error
message, e.g. DivisionUndefined: (InvalidOperation) 0/0, but this
doesn't seem worth changing to me.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7046>
_______________________________________
More information about the Python-bugs-list
mailing list