Message300958
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())
) |
|
Date |
User |
Action |
Args |
2017-08-28 18:23:31 | Oren Milman | set | recipients:
+ Oren Milman, belopolsky, serhiy.storchaka |
2017-08-28 18:23:30 | Oren Milman | set | messageid: <1503944610.97.0.775813417201.issue31293@psf.upfronthosting.co.za> |
2017-08-28 18:23:30 | Oren Milman | link | issue31293 messages |
2017-08-28 18:23:30 | Oren Milman | create | |
|