[issue47121] math.isfinite() can raise exception when called on a number
Raymond Hettinger
report at bugs.python.org
Fri Mar 25 13:52:35 EDT 2022
Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:
The math.isfinite() docs could be changed to something like, "coerces x to a float if possible and then returns True if x is neither an infinity nor a NaN, and False otherwise." Or there could be a general note about which functions (most of them) coerce to float (which can fail).
With respect to typing and PEP-484, I don't see a bug or documentation issue. Types relationships are useful for verifying which methods are available, but they don't make promises about the range of valid values. For example math.sqrt(float) -> float promises which types are acceptable but doesn't promise that negative inputs won't raise an exception. Likewise, "n: int=10; len(range(n))" is type correct but will raise an OverflowError for "n = 10**100".
----------
assignee: -> docs at python
components: +Documentation
nosy: +docs at python, rhettinger
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue47121>
_______________________________________
More information about the Python-bugs-list
mailing list