Closed
Description
Documentation says: Raises ValueError if n is not integral or is negative.
Docstring: Raise a ValueError if x is negative or non-integral.
State of art:
>>> math.factorial(1.0)
Traceback (most recent call last):
File "<python-input-2>", line 1, in <module>
math.factorial(1.0)
~~~~~~~~~~~~~~^^^^^
TypeError: 'float' object cannot be interpreted as an integer
>>> math.factorial(-1.0)
Traceback (most recent call last):
File "<python-input-3>", line 1, in <module>
math.factorial(-1.0)
~~~~~~~~~~~~~~^^^^^^
TypeError: 'float' object cannot be interpreted as an integer
>>> math.factorial(-1)
Traceback (most recent call last):
File "<python-input-4>", line 1, in <module>
math.factorial(-1)
~~~~~~~~~~~~~~^^^^
ValueError: factorial() not defined for negative values
Documentation should be fixed to state, that TypeError is raised for non-integral arguments.
Or just omit description of exceptions and reduce docs to: "Return factorial of the nonnegative integer n."
Linked PRs
Metadata
Metadata
Assignees
Projects
Status
Todo