[Email-SIG] Non-string headers

Barry Warsaw barry at python.org
Tue Apr 20 16:08:14 EDT 2004


On Tue, 2004-04-20 at 15:59, Matthew Dixon Cowles wrote:
> [Barry]
> > Rather than relax the values that a header can have, I'm inclined
> > to tighten them.  The rule could be that the header value must be a
> > Unicode string, or an instance providing a particular interface
> > (which by default Headers would implement).  This way, raw 8-bit
> > strings would be out (mixing 8-bit and Unicodes is evil anyway :),
> > and you could always wrap your values in an instance that supported
> > the given interface. Accepting Unicodes would be a convenience for
> > the simple case.
> 
> That makes sense to me as long as plain 7-bit strings are allowed. I
> assume that falls out of what's above, but I don't quite see it.

Maybe, if the value wasn't a Header or a unicode, I'd do a unicode(s,
'ascii') conversion on it and convert any UnicodeError to a TypeError. 
That's a bit of a slippery slope though because some will argue we
should do 'latin-1' and maybe other conversions implicitly too.  I'd
stop at 'ascii'.

-Barry





More information about the Email-SIG mailing list