From 43d61f938e800a4e177f9fd272c0eb128cc399a0 Mon Sep 17 00:00:00 2001
From: mkaraev <maruf.karaev97@gmail.com>
Date: Mon, 12 May 2025 14:41:15 +0500
Subject: [PATCH] gh-133904: Fix `math.factorial` documentation (GH-133907)
 (cherry picked from commit 27ed64575d34f04029ba1d353810f3db4f4f045b)

Co-authored-by: mkaraev <maruf.karaev97@gmail.com>
Co-authored-by: sobolevn <mail@sobolevn.me>
---
 Doc/library/math.rst          | 3 +--
 Modules/clinic/mathmodule.c.h | 6 ++----
 Modules/mathmodule.c          | 4 +---
 3 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/Doc/library/math.rst b/Doc/library/math.rst
index 0749367045dfa9..394a462b9468e5 100644
--- a/Doc/library/math.rst
+++ b/Doc/library/math.rst
@@ -144,8 +144,7 @@ Number-theoretic functions
 
 .. function:: factorial(n)
 
-   Return *n* factorial as an integer.  Raises :exc:`ValueError` if *n* is not integral or
-   is negative.
+   Return factorial of the nonnegative integer *n*.
 
    .. versionchanged:: 3.10
       Floats with integral values (like ``5.0``) are no longer accepted.
diff --git a/Modules/clinic/mathmodule.c.h b/Modules/clinic/mathmodule.c.h
index 4c2c8acd8f69d8..9df73b187bb827 100644
--- a/Modules/clinic/mathmodule.c.h
+++ b/Modules/clinic/mathmodule.c.h
@@ -108,9 +108,7 @@ PyDoc_STRVAR(math_factorial__doc__,
 "factorial($module, n, /)\n"
 "--\n"
 "\n"
-"Find n!.\n"
-"\n"
-"Raise a ValueError if x is negative or non-integral.");
+"Find n!.");
 
 #define MATH_FACTORIAL_METHODDEF    \
     {"factorial", (PyCFunction)math_factorial, METH_O, math_factorial__doc__},
@@ -1112,4 +1110,4 @@ math_ulp(PyObject *module, PyObject *arg)
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=634773bd18cd3f93 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=77e7b8c161c39843 input=a9049054013a1b77]*/
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
index 11d9b7418a25a2..40abd69f0a6600 100644
--- a/Modules/mathmodule.c
+++ b/Modules/mathmodule.c
@@ -2008,13 +2008,11 @@ math.factorial
     /
 
 Find n!.
-
-Raise a ValueError if x is negative or non-integral.
 [clinic start generated code]*/
 
 static PyObject *
 math_factorial(PyObject *module, PyObject *arg)
-/*[clinic end generated code: output=6686f26fae00e9ca input=713fb771677e8c31]*/
+/*[clinic end generated code: output=6686f26fae00e9ca input=366cc321df3d4773]*/
 {
     long x, two_valuation;
     int overflow;