[Spambayes] Eliminating duplicates from mbox file

Tim Peters tim.one at comcast.net
Sat Mar 8 00:01:05 EST 2003


[Skip Montanaro]
> Yuck, badly worded.  I should have said something like
>
>     Yeah, I know.  That's how I originally wrote it.  After subclassing
>     PortableUnixMailbox to get the "for msg in mbox:" to succeed, without
>     the test against None in the loop it just went into an infloop.

Except that you shouldn't have needed to subclass, just as the sample code I
showed didn't need to subclass.  That's where the problem lies.  After you
subclassed it, the None problem was probably due to the subclassing (indeed,
it clearly was due to the subclassing:  you had your subclass __iter__
return self, and self.next() can return None then; the
mailbox.PortableUnixMailbox.__iter__ returns iter(self.next, None), which
cannot return None).

To get anywhere else with this and without benefit of telepathy, you should
create a self-contained small test case and make sure you're using a
self-consistent set of factory-standard <wink> software.  The problem is why
you needed to subclass to begin with:  as you orginally noted,
mailbox.PortableUnixMailbox already supplied __iter__, so it makes no sense
that you had to supply your own.  Something else is wrong.




More information about the Spambayes mailing list