[New-bugs-announce] [issue47121] math.isfinite() can raise exception when called on a number
report at bugs.python.org
Fri Mar 25 13:28:43 EDT 2022
New submission from Thomas Fischbacher <tfish at google.com>:
Return True if x is neither an infinity nor a NaN, and False otherwise.
So, one would expect the following expression to return `True` or `False`. We instead observe:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: int too large to convert to float
(There likewise is a corresponding issue with other, similar, functions).
This especially hurts since PEP-484 states that having a Sequence[float] `xs` does not allow us to infer that `all(issubclass(type(x), float) for x in xs)` actually holds - since a PEP-484 "float" actually does also include "int" (and still, issubclass(int, float) == False).
Now, strictly speaking, `help(math)` states that
This module provides access to the mathematical functions
defined by the C standard.
...but according to "man 3 isfinite", the math.h "isfinite" is a macro and not a function - and the man page does not show type information for that reason.
title: math.isfinite() can raise exception when called on a number
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce