[issue47121] math.isfinite() can raise exception when called on a number

2022-04-08 Thread Thomas Fischbacher
Thomas Fischbacher added the comment: Tim, the problem may well be simply due to the documentation of math.isfinite() being off here. This is what we currently have: https://docs.python.org/3/library/math.html#math.isfinite === math.isfinite(x) Return True if x is neither an infinity nor a

[issue47121] math.isfinite() can raise exception when called on a number

2022-04-05 Thread Tim Peters
Tim Peters added the comment: I'll testify that I won't volunteer one second of my time pursuing these abstract "purity" crusades ;-) `isfinite()` et alia were added to supply functions defined by current standards to work on IEEE floating-point values. People working with floats have

[issue47121] math.isfinite() can raise exception when called on a number

2022-04-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: > isfinite() should return True for all ints, without needing > to coerce them to float Whoa there. You're venturing into changing what those math functions were all about and the core approach to how they operate. A zigzag to this new direction would

[issue47121] math.isfinite() can raise exception when called on a number

2022-04-05 Thread Steven D'Aprano
Steven D'Aprano added the comment: 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

[issue47121] math.isfinite() can raise exception when called on a number

2022-03-25 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Most (but not all) functions in the math module implicitly convert its arguments to float. Here we can get an OverflowError. Do we want to add a note to every function that does it? Or add a general note at the top of the file and add exclusion notes to

[issue47121] math.isfinite() can raise exception when called on a number

2022-03-25 Thread Thomas Fischbacher
Thomas Fischbacher added the comment: The problem with PEP-484 is that if one wants to use static type analysis, neither of these options are good: - Use static annotations on functions, and additionally spec out expectations in docstrings. Do note that the two types places where "float"

[issue47121] math.isfinite() can raise exception when called on a number

2022-03-25 Thread Raymond Hettinger
Raymond Hettinger 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)

[issue47121] math.isfinite() can raise exception when called on a number

2022-03-25 Thread Nathaniel Manista
Change by Nathaniel Manista : -- nosy: +Nathaniel Manista ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue47121] math.isfinite() can raise exception when called on a number

2022-03-25 Thread Thomas Fischbacher
New submission from Thomas Fischbacher : >>> help(math.isfinite) isfinite(x, /) 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: >>> math.isfinite(10**1000) Traceback