-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixesdocsDocumentation in the Doc dirDocumentation in the Doc direasy
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
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixesdocsDocumentation in the Doc dirDocumentation in the Doc direasy
Projects
Status
Todo