[issue8567] decimal module doesn't respect precedence rules for exceptional conditions

Stefan Krah report at bugs.python.org
Thu Apr 29 15:23:51 CEST 2010


Stefan Krah <stefan-usenet at bytereef.org> added the comment:

Mark,

I'm very short of time today, so I hope I don't miss anything that you
wrote.

The model of decNumber (and libmpdec) is to accumulate any status
(flags) that occurs in a function, regardless of whether a signal
is trapped or not. 

Only at function exit the traps are checked. If multiple exceptions
could be raised, the order of precedence applies. All status that
has been accumulated in the function remains in the context.


This would be backed up by:

http://speleotrove.com/decimal/damodel.html

  ==>  flags and trap-enablers:

  ==> "For each of the signals, the corresponding flag is set to 1
       when the signal occurs. It is only reset to 0 by explicit
       user action."


So, in your example, in cdecimal I get:
>>> from cdecimal import *
>>> getcontext().traps[Inexact] = True
>>> Decimal('1e100').exp()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
cdecimal.Overflow: [<class 'cdecimal.Overflow'>, <class 'cdecimal.Inexact'>]


In the square brackets I list all signals that occurred _and_ are
trapped.





 

  "

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8567>
_______________________________________


More information about the Python-bugs-list mailing list