mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
bpo-37315: Deprecate accepting floats in math.factorial(). (GH-14147)
This commit is contained in:
parent
1ce2656f13
commit
231aad3849
5 changed files with 28 additions and 7 deletions
|
@ -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))) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue