[issue1823] Possible to set invalid Content-Transfer-Encoding on email.mime.multipart.MIMEMultipart

Chris Withers report at bugs.python.org
Thu Mar 5 14:06:55 CET 2009


Chris Withers <chris at simplistix.co.uk> added the comment:

Okay, splitting this out a little. I've moved the exception when setting  
character set after adding parts out to [Issue5423].

Here's a simpler example of the problem with setting character sets on 
multiparts:

>>> from email.MIMEMultipart import MIMEMultipart
>>> msg = MIMEMultipart()
>>> msg.set_charset('iso-8859-15')
>>> print msg.as_string()
MIME-Version: 1.0
Content-Type: multipart/mixed; charset="iso-8859-15";
        boundary="===============1300027372=="
Content-Transfer-Encoding: quoted-printable

As a programmer, I don't think I've done anything wrong, but that mail 
is not valid and causes some fussy MTAs to barf and show the message as 
blank.

That said, when would you ever need or want to set the character set on 
a MIMEMultipart? I have this in my code, but I suspect I was just 
sheep/paranoia programming. When would just making set_charset on a 
MIMEMultipart raise an exception cause problems?

----------
nosy: +cjw296

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1823>
_______________________________________


More information about the Python-bugs-list mailing list