[PATCH v2 09/10] parsemail: Convert to a management command

Daniel Axtens dja at axtens.net
Sun Aug 28 21:10:33 AEST 2016


Daniel Axtens <dja at axtens.net> writes:


> with open(args[0], 'rb') as file_:
>      decoded_mail = file_.read().decode('utf-8')
>      mail = email.message_from_string(decoded_mail)
>
> This is super ugly, but works in Py3. Ironically it doesn't work in Py2,
> but it's a start. Could you include something like this in this patch
> set? I think the parsearchive will require something similar too.

Looks like there's message_from_bytes and message_from_binary_file in
recent versions of 'email' - I haven't tried but I assume that would be
better. Anyway, I'll leave it to your judgement.

Regards,
Daniel
>
> I'm going to start collecting these "interesting" emails to make a test suite.
>
> Regards,
> Daniel
>
> [0] https://lists.ozlabs.org/pipermail/patchwork/2016-August/003158.html


More information about the Patchwork mailing list