Re: headers api for email package

Chris Withers <[email protected]>
Newsgroups gmane.comp.python.devel,gmane.comp.python.mime.devel
Message-ID <[email protected]>
>>> Where you just want "a damned valid email and stop making my life 
>>> hard!":
>>>
>>> Message['Subject']='Some text'
>>
>> Yes.  In which case I propose we guess the encoding as 1) ascii, 2) 
>> utf-8, 3) wtf?

Well, we're talking about Python 3 here right? In which case the above 
involves only unicode, so why do we need to guess anything? Just use 
utf-8 and be done with it...

> However, it's not supposed to be used by mail composers, who are
> expected to know the encoding.  It's for mail gateways that are
> transforming something and don't know the encoding.  I'm not
> sure what this means for the email module, which certainly
> will be used in a mail gateways....maybe it's the responsibility
> of the application code to explicitly say 'unknown encoding'?

Indeed, surely this happens when you have bytes and need to do something 
with it? That's not what my example above is about...

>>> Where you care about what encoding is used:
>>>
>>> Message['Subject']=Header('Some text',encoding='utf-8')
>>
>> Yes.

...it's covered by this.

>>> If you have bytes, for whatever reason:
>>>
>>> Message['Subject']=b'some bytes'.decode('utf-8')
>>>
>>> ...because only you know what encoding those bytes use!
>>
>> So you're saying that __setitem__() should not accept raw bytes?

Indeed :-)

Chris

-- 
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/python-python-dev%40m.gmane.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.