Author Oren Milman
Recipients Oren Milman, belopolsky, serhiy.storchaka
Date 2017-08-28.18:23:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1503944610.97.0.775813417201.issue31293@psf.upfronthosting.co.za>
In-reply-to
Content
I guess you meant for me to check whether the following has any problem:
import decimal

class BadFloat(float):
    def as_integer_ratio(self):
        return 1 << 1000

decimal.Decimal.from_float(BadFloat())

so it doesn't crash.
if IIUC, this is because the C implementation of Decimal.from_float()
is PyDecType_FromFloat(), while the relevant part of it is a call to
PyDecType_FromFloatExact().
But PyDecType_FromFloatExact() uses float.as_integer_ratio(), and thus
ISTM that the issue doesn't exist there.

(also, the following doesn't raise an exception, as expected:
import decimal

class BadFloat(float):
    def as_integer_ratio(self):
        raise RuntimeError

decimal.Decimal.from_float(BadFloat())
)
History
Date User Action Args
2017-08-28 18:23:31Oren Milmansetrecipients: + Oren Milman, belopolsky, serhiy.storchaka
2017-08-28 18:23:30Oren Milmansetmessageid: <1503944610.97.0.775813417201.issue31293@psf.upfronthosting.co.za>
2017-08-28 18:23:30Oren Milmanlinkissue31293 messages
2017-08-28 18:23:30Oren Milmancreate