Reading and writing Mozilla-mail in python
Tim Roberts
timr at probo.com
Fri Dec 12 00:57:22 EST 2003
Uwe Grauer <news at grauer-online.de> wrote:
>After playing around with the mailbox an email modules i noticed some
>strange behaviours:
>
>after the first message is parsed, i got some (kind of parsing errors).
>
>My code:
>
>def test_copy(infile, outfile):
> from mailbox import UnixMailbox
> from email import message_from_file as mff
> try:
> fd = open(infile, 'r')
Ralf is correct. The UnixMailbox method uses tell and seek to remember
file locations and return to them later. Tell and seek on Windows are only
valid with binary files; the \r\n to \n translation screws it up.
Change that to
fd = open(infile, 'rb')
and all will be well.
--
- Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list