diff options
-rw-r--r-- | Modules/itertoolsmodule.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index 4efde75..2ee947d 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -2111,8 +2111,11 @@ combinations_next(combinationsobject *co) } Py_DECREF(old_result); } - /* Now, we've got the only copy so we can update it in-place */ - assert (Py_REFCNT(result) == 1); + /* Now, we've got the only copy so we can update it in-place + * CPython's empty tuple is a singleton and cached in + * PyTuple's freelist. + */ + assert(r == 0 || Py_REFCNT(result) == 1); /* Scan indices right-to-left until finding one that is not at its maximum (i + n - r). */ |