From 231aad38493c871dd32930a21d256cbacd2ae20c Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 17 Jun 2019 16:57:27 +0300 Subject: bpo-37315: Deprecate accepting floats in math.factorial(). (GH-14147) --- Modules/mathmodule.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Modules/mathmodule.c') diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index 82a9a14724..a75a3c929e 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -1981,6 +1981,12 @@ math_factorial(PyObject *module, PyObject *arg) 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))) { -- cgit v1.2.1