[Python-3000] email libraries: use byte or unicode strings?

Andrew McNamara andrewm at object-craft.com.au
Thu Oct 30 23:17:25 CET 2008


>>What about smtplib or smtpd?
>
>Yes, they should use bytes, 

I agree. imaplib, poplib and smtplib are wire protocols, and should be
8-bit clean (SMTP in particular). The APIs are little more than the wire
protocol, so I think it's apprioriate they present bytes to their users
also (and there is nothing in their respective RFC's about encoding).

>as should the email package.  

That's a tricker case, but I think it should use bytes internally. One of
the early goals of email was that be able to cope with malformed MIME -
this includes incorrectly encoded messages. So I think it must keep a
bytes representation internally.

However - charset encoding is part of the MIME spec, so users have a
reasonable expectation that the mime lib will present them with unicode.
So the API needs to be unicode.

>The latter doesn't though, and it needs a lot of work (we tried and failed
>at pycon).

Yes, it's hard. I think we're going to have to break the API.

-- 
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/


More information about the Python-3000 mailing list