Mark Dickinson <dicki...@gmail.com> added the comment:

Yes, that's a good point.  It would be nice for e.g. "Inexact => Rounded" 
invariants to be, well, invariant.

I agree that the cdecimal behaviour is the correct one.  I'm looking for wiggle 
room here because I don't really want to make a set of complicated and possibly 
performance-degrading changes to the decimal module unless it's really 
necessary for correctness.

Having said that, I can see at least one reasonable way of fixing this in the 
decimal module:

(1) Create a "delay_traps" context manager, so that:

with delay_traps():
    <do arithmetic>

disables traps for the duration of the with block, keeps track of all flags set 
(disregarding those set before the with block was entered), and then on leaving 
the with block re-raises signals corresponding to the traps set in the original 
context (respecting precedence, of course).

(2) Also create a "_delayed_traps" (names could do with improvement, probably) 
decorator that effectively wraps an entire function in 'with delay_traps()"

(3) Decorate all the primitive decimal operations with this decorator.

Thoughts?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8613>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to