This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients facundobatista, mark.dickinson, rhettinger, skrah
Date 2010-05-05.12:27:56
SpamBayes Score 9.329474e-05
Marked as misclassified No
Message-id <1273062479.55.0.0205355704293.issue8613@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2010-05-05 12:27:59mark.dickinsonsetrecipients: + mark.dickinson, rhettinger, facundobatista, skrah
2010-05-05 12:27:59mark.dickinsonsetmessageid: <1273062479.55.0.0205355704293.issue8613@psf.upfronthosting.co.za>
2010-05-05 12:27:58mark.dickinsonlinkissue8613 messages
2010-05-05 12:27:56mark.dickinsoncreate