diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-09-28 12:56:52 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-28 12:56:52 (GMT) |
commit | fd52afd1928643a715202147b1ce5b0d130ec252 (patch) | |
tree | 28a65cc5dc175d275bf70eb3a1b036af453b37bd /Modules | |
parent | acd46feff3c06d3f1d00ab850e530c519445a737 (diff) | |
download | cpython-fd52afd1928643a715202147b1ce5b0d130ec252.zip cpython-fd52afd1928643a715202147b1ce5b0d130ec252.tar.gz cpython-fd52afd1928643a715202147b1ce5b0d130ec252.tar.bz2 |
bpo-35606: Fix math.prod tests using 'start' as keyword parameter (GH-28595)
(cherry picked from commit 84975146a7ce64f1d50dcec8311b7f7188a5c962)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Diffstat (limited to 'Modules')
-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 a2a2db2..16da008 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -3081,14 +3081,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. @@ -3104,7 +3099,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); |