bpo-37315: Deprecate accepting floats in math.factorial(). (GH-14147)
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
index 82a9a14..a75a3c9 100644
--- a/Modules/mathmodule.c
+++ b/Modules/mathmodule.c
@@ -1981,6 +1981,12 @@
PyObject *result, *odd_part, *pyint_form;
if (PyFloat_Check(arg)) {
+ if (PyErr_WarnEx(PyExc_DeprecationWarning,
+ "Using factorial() with floats is deprecated",
+ 1) < 0)
+ {
+ return NULL;
+ }
PyObject *lx;
double dx = PyFloat_AS_DOUBLE((PyFloatObject *)arg);
if (!(Py_IS_FINITE(dx) && dx == floor(dx))) {