Where you just want "a damned valid email and stop making my life hard!":
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:
...it's covered by this.
If you have bytes, for whatever reason:
...because only you know what encoding those bytes use!
So you're saying that __setitem__() should not accept raw bytes?
-- Simplistix - Content Management, Zope & Python Consulting