summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-09-24 10:36:11 (GMT)
committerGitHub <noreply@github.com>2017-09-24 10:36:11 (GMT)
commitc247caf33f6e6000d828db4762d1cb12edf3cd57 (patch)
tree85caedaba2394380c428839bda687f23dd853e43 /Doc
parent4facdf523aa6967487a9425f124da9661b59fd43 (diff)
downloadcpython-c247caf33f6e6000d828db4762d1cb12edf3cd57.zip
cpython-c247caf33f6e6000d828db4762d1cb12edf3cd57.tar.gz
cpython-c247caf33f6e6000d828db4762d1cb12edf3cd57.tar.bz2
bpo-30346: An iterator produced by the itertools.groupby() iterator (#1569)
now becames exhausted after advancing the groupby iterator.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/itertools.rst7
1 files changed, 4 insertions, 3 deletions
diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst
index c989e46..530c29d 100644
--- a/Doc/library/itertools.rst
+++ b/Doc/library/itertools.rst
@@ -401,13 +401,14 @@ loops that truncate the stream.
def __iter__(self):
return self
def __next__(self):
+ self.id = object()
while self.currkey == self.tgtkey:
self.currvalue = next(self.it) # Exit on StopIteration
self.currkey = self.keyfunc(self.currvalue)
self.tgtkey = self.currkey
- return (self.currkey, self._grouper(self.tgtkey))
- def _grouper(self, tgtkey):
- while self.currkey == tgtkey:
+ return (self.currkey, self._grouper(self.tgtkey, self.id))
+ def _grouper(self, tgtkey, id):
+ while self.id is id and self.currkey == tgtkey:
yield self.currvalue
try:
self.currvalue = next(self.it)