[Python-checkins] bpo-24076: Fix reference in sum() introduced by GH-28469 (GH-28493)

pablogsal webhook-mailer at python.org
Tue Sep 21 13:39:12 EDT 2021


https://github.com/python/cpython/commit/1c7e98dc258a0e7ccd2325a1aefc4aa2de51e1c5
commit: 1c7e98dc258a0e7ccd2325a1aefc4aa2de51e1c5
branch: main
author: Pablo Galindo Salgado <Pablogsal at gmail.com>
committer: pablogsal <Pablogsal at gmail.com>
date: 2021-09-21T18:38:57+01:00
summary:

bpo-24076: Fix reference in sum() introduced by GH-28469 (GH-28493)

files:
M Python/bltinmodule.c

diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 38bdfb2766f3d..d0d31805b3018 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -2484,7 +2484,8 @@ builtin_sum_impl(PyObject *module, PyObject *iterable, PyObject *start)
                 /* Single digits are common, fast, and cannot overflow on unpacking. */
                 switch (Py_SIZE(item)) {
                     case -1: b = -(sdigit) ((PyLongObject*)item)->ob_digit[0]; break;
-                    case  0: continue;
+                    // Note: the continue goes to the top of the "while" loop that iterates over the elements
+                    case  0: Py_DECREF(item); continue; 
                     case  1: b = ((PyLongObject*)item)->ob_digit[0]; break;
                     default: b = PyLong_AsLongAndOverflow(item, &overflow); break;
                 }



More information about the Python-checkins mailing list