]> granicus.if.org Git - python/commitdiff
SF bug #461073: mailbox __iter__ bug, by Andrew Dalke.
authorGuido van Rossum <guido@python.org>
Thu, 13 Sep 2001 01:29:13 +0000 (01:29 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 13 Sep 2001 01:29:13 +0000 (01:29 +0000)
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.

Lib/mailbox.py

index 98e61f2e07d991938d2709e1cb109019e7945249..b1c082dd531202bcc07586d3a2df2348872bfd6d 100755 (executable)
@@ -15,7 +15,7 @@ class _Mailbox:
         self.factory = factory
 
     def __iter__(self):
-        return self
+        return iter(self.next, None)
 
     def next(self):
         while 1:
@@ -195,7 +195,7 @@ class MHMailbox:
         self.factory = factory
 
     def __iter__(self):
-        return self
+        return iter(self.next, None)
 
     def next(self):
         if not self.boxes:
@@ -226,7 +226,7 @@ class Maildir:
         self.boxes = boxes
 
     def __iter__(self):
-        return self
+        return iter(self.next, None)
 
     def next(self):
         if not self.boxes: