[Python-checkins] cpython (merge 3.4 -> 3.5): merge

raymond.hettinger python-checkins at python.org
Tue Jul 28 11:08:25 CEST 2015


https://hg.python.org/cpython/rev/e21d5b7f1efa
changeset:   97099:e21d5b7f1efa
branch:      3.5
parent:      97094:0e8fc11cbfca
parent:      97098:fd3fb122c5ff
user:        Raymond Hettinger <python at rcn.com>
date:        Tue Jul 28 02:07:14 2015 -0700
summary:
  merge

files:
  Modules/itertoolsmodule.c |  12 +++++++-----
  1 files changed, 7 insertions(+), 5 deletions(-)


diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -2787,11 +2787,13 @@
         if (result == NULL)
             goto empty;
         co->result = result;
-        elem = PyTuple_GET_ITEM(pool, 0);
-        for (i=0; i<r ; i++) {
-            assert(indices[i] == 0);
-            Py_INCREF(elem);
-            PyTuple_SET_ITEM(result, i, elem);
+        if (n > 0) {
+            elem = PyTuple_GET_ITEM(pool, 0);
+            for (i=0; i<r ; i++) {
+                assert(indices[i] == 0);
+                Py_INCREF(elem);
+                PyTuple_SET_ITEM(result, i, elem);
+            }
         }
     } else {
         /* Copy the previous result tuple or re-use it if available */

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list