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 skrah
Recipients mark.dickinson, pitrou, skrah, steven.daprano
Date 2012-08-04.18:52:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <20120804185218.GA18594@sleipnir.bytereef.org>
In-reply-to <1344102329.03.0.136141685812.issue15544@psf.upfronthosting.co.za>
Content
Mark Dickinson <report@bugs.python.org> wrote:
> Looks like we've got two separate issues here, that should probably be
> split into two separate bug reports.  The first issue is that
> Decimal.__float__ is brain-dead when it comes to NaNs with payloads;
> I consider that a clear bug, and Steven's patch fixes it nicely for
> the Python version of decimal.

If we are viewing the whole issue in terms of decimal -> float conversion,
I'm not so sure anymore: Not all Decimal payloads have a meaning for floats
(and payloads get lost in the conversion).

On the other hand it doesn't matter since I doubt anyone is using payloads. :)

> The second has to do with finding a nice type-agnostic way of determing
> whether something is a NaN---anyone mind if I open a separate issue for this?

Yes, that should probably be another issue.

> Two questions:  (1) What would you think about raising ValueError explicitly
> for the signaling NaN case rather than falling back to the ValueError coming
> from the string-to-float conversion.

If we use your latest rationale for raising in case of Decimal('snan').__float__(),
I think that indeed __float__() should raise like Decimal.to_integral() does
for example.

If we are aiming for sNaN support in floats in the long term and at some point
allow carrying over sNaNs from decimal to float, then perhaps the error message
could say that sNaN conversion is currently not supported.

> (2) Should we apply the fix to 2.7 and/or 3.2 as well?

Yes, I think so.

> I'll look at extending Steven's fix to the cdecimal code, unless Stefan
> really wants to do it (which would be fine with me :-).

Please go ahead! For this year, I've seen more than enough of _decimal.c
already. :)
History
Date User Action Args
2012-08-04 18:52:19skrahsetrecipients: + skrah, mark.dickinson, pitrou, steven.daprano
2012-08-04 18:52:18skrahlinkissue15544 messages
2012-08-04 18:52:17skrahcreate