diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2021-09-28 12:32:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-28 12:32:43 (GMT) |
commit | 84975146a7ce64f1d50dcec8311b7f7188a5c962 (patch) | |
tree | d2e0700eefee71f0568773bde7f13d6679a4aa66 /Modules/mathmodule.c | |
parent | e649e0658ff2af87b07d994c05ae048e16e31aae (diff) | |
download | cpython-84975146a7ce64f1d50dcec8311b7f7188a5c962.zip cpython-84975146a7ce64f1d50dcec8311b7f7188a5c962.tar.gz cpython-84975146a7ce64f1d50dcec8311b7f7188a5c962.tar.bz2 |
bpo-35606: Fix math.prod tests using 'start' as keyword parameter (GH-28595)
Diffstat (limited to 'Modules/mathmodule.c')
-rw-r--r-- | Modules/mathmodule.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index bd97b03..5e9f63f 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -3082,14 +3082,9 @@ math_prod_impl(PyObject *module, PyObject *iterable, PyObject *start) } if (result == NULL) { - result = PyLong_FromLong(1); - if (result == NULL) { - Py_DECREF(iter); - return NULL; - } - } else { - Py_INCREF(result); + result = _PyLong_GetOne(); } + Py_INCREF(result); #ifndef SLOW_PROD /* Fast paths for integers keeping temporary products in C. * Assumes all inputs are the same type. @@ -3105,7 +3100,7 @@ math_prod_impl(PyObject *module, PyObject *iterable, PyObject *start) } /* Loop over all the items in the iterable until we finish, we overflow * or we found a non integer element */ - while(result == NULL) { + while (result == NULL) { item = PyIter_Next(iter); if (item == NULL) { Py_DECREF(iter); |