[Python-checkins] r69009 - in python/branches/release26-maint: Doc/library/itertools.rst Lib/test/test_itertools.py
raymond.hettinger
python-checkins at python.org
Tue Jan 27 07:38:01 CET 2009
Author: raymond.hettinger
Date: Tue Jan 27 07:38:00 2009
New Revision: 69009
Log:
Fixup itertools recipe to cover a corner case.
Modified:
python/branches/release26-maint/Doc/library/itertools.rst
python/branches/release26-maint/Lib/test/test_itertools.py
Modified: python/branches/release26-maint/Doc/library/itertools.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/itertools.rst (original)
+++ python/branches/release26-maint/Doc/library/itertools.rst Tue Jan 27 07:38:00 2009
@@ -686,6 +686,8 @@
# number items returned: (n+r-1)! / r! / (n-1)!
pool = tuple(iterable)
n = len(pool)
+ if not n and r:
+ return
indices = [0] * r
yield tuple(pool[i] for i in indices)
while 1:
Modified: python/branches/release26-maint/Lib/test/test_itertools.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_itertools.py (original)
+++ python/branches/release26-maint/Lib/test/test_itertools.py Tue Jan 27 07:38:00 2009
@@ -1268,6 +1268,8 @@
... "combinations_with_replacement('ABC', 3) --> AA AB AC BB BC CC"
... pool = tuple(iterable)
... n = len(pool)
+... if not n and r:
+... return
... indices = [0] * r
... yield tuple(pool[i] for i in indices)
... while 1:
More information about the Python-checkins
mailing list