[Python-Dev] Dropping bytes "support" in json

Aahz aahz at pythoncraft.com
Fri Apr 10 04:52:03 CEST 2009

On Thu, Apr 09, 2009, Barry Warsaw wrote:
> So, what I'm really asking is this.  Let's say you agree that there are 
> use cases for accessing a header value as either the raw encoded bytes or 
> the decoded unicode.  What should this return:
> >>> message['Subject']
> The raw bytes or the decoded unicode?

Let's make that the raw bytes by default -- we can add a parameter to
Message() to specify that the default where possible is unicode for
returned values, if that isn't too painful.

Here's my reasoning: ultimately, everyone NEEDS to understand that the
underlying transport for e-mail is bytes (similar to sockets).  We do
people no favors by pasting over this too much.  We can overlay
convenience at various points, but except for text payloads, everything
should be bytes by default.  

Even for text payloads, I'm not entirely certain the default shouldn't be
bytes: consider an HTML attachment that you want to compare against the
output from a webserver.  Still, as long as it's easy to get bytes for
text payloads, I think overall I'm still leaning toward unicode for them.
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Why is this newsgroup different from all other newsgroups?

More information about the Python-Dev mailing list