Oren Milman added the comment: 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()) ) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue31293> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com