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 steven.daprano
Recipients Nathaniel Manista, docs@python, rhettinger, serhiy.storchaka, steven.daprano, tfish2
Date 2022-04-06.02:51:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1649213460.27.0.213982597123.issue47121@roundup.psfhosted.org>
In-reply-to
Content
Isn't this just a quality of implementation issue?

math.isfinite should return True for all ints, since all ints are finite. (There are no int infinities or NANs). There is no need to coerce them to float to know that they are finite.

Likewise for Fractions. If they overflow, that could be caught and True returned.

Decimal infinities convert to float infinities, so the only way you can get an overflow error is if the Decimal is finite but too big to convert. So again, isfinite could (should?) catch the overflow error and return True.

Any numeric type that has an infinity which does not coerce to float infinity, but overflows instead, is buggy, and its not isfinite's responsibility to protect against that.

So here is my suggestion:

isfinite() should return True for all ints, without needing to coerce them to float. For other numeric types, it should try to coerce them to float, and catch OverflowError and raise True. This should be documented, so that other numeric types know what contract they are required to follow (infinity coerces to float infinity).

I'm going to change this to an enhancement for 3.11 (or 3.12).
History
Date User Action Args
2022-04-06 02:51:00steven.dapranosetrecipients: + steven.daprano, rhettinger, docs@python, serhiy.storchaka, Nathaniel Manista, tfish2
2022-04-06 02:51:00steven.dapranosetmessageid: <1649213460.27.0.213982597123.issue47121@roundup.psfhosted.org>
2022-04-06 02:51:00steven.dapranolinkissue47121 messages
2022-04-06 02:51:00steven.dapranocreate