mirror of https://github.com/python/cpython
SF bug #461073: mailbox __iter__ bug, by Andrew Dalke.
Andrew quite correctly notices that the next() method isn't quite what we need, since it returns None upon end instead of raising StopIteration. His fix is easy enough, using iter(self.next, None) instead.
This commit is contained in:
parent
1f47d11ff2
commit
93a696f491
|
@ -15,7 +15,7 @@ class _Mailbox:
|
||||||
self.factory = factory
|
self.factory = factory
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return self
|
return iter(self.next, None)
|
||||||
|
|
||||||
def next(self):
|
def next(self):
|
||||||
while 1:
|
while 1:
|
||||||
|
@ -195,7 +195,7 @@ class MHMailbox:
|
||||||
self.factory = factory
|
self.factory = factory
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return self
|
return iter(self.next, None)
|
||||||
|
|
||||||
def next(self):
|
def next(self):
|
||||||
if not self.boxes:
|
if not self.boxes:
|
||||||
|
@ -226,7 +226,7 @@ class Maildir:
|
||||||
self.boxes = boxes
|
self.boxes = boxes
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return self
|
return iter(self.next, None)
|
||||||
|
|
||||||
def next(self):
|
def next(self):
|
||||||
if not self.boxes:
|
if not self.boxes:
|
||||||
|
|
Loading…
Reference in New Issue