From: R David Murray Date: Tue, 19 Mar 2013 22:21:22 +0000 (-0400) Subject: Merge: #1525919: Document MIMEText+set_payload encoding behavior. X-Git-Tag: v3.3.1rc1~29^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=432a48a0c8b157fe09ed9cc09cd47754f0ef7eac;p=thirdparty%2FPython%2Fcpython.git Merge: #1525919: Document MIMEText+set_payload encoding behavior. --- 432a48a0c8b157fe09ed9cc09cd47754f0ef7eac diff --cc Doc/library/email.mime.rst index db5584c905aa,2ce486820f0a..acaba1ce4003 --- a/Doc/library/email.mime.rst +++ b/Doc/library/email.mime.rst @@@ -185,5 -185,15 +185,15 @@@ Here are the classes minor type and defaults to :mimetype:`plain`. *_charset* is the character set of the text and is passed as a parameter to the :class:`~email.mime.nonmultipart.MIMENonMultipart` constructor; it defaults - to ``us-ascii``. + to ``us-ascii`` if the string contains only ``ascii`` codepoints, and + ``utf-8`` otherwise. + + Unless the ``_charset`` parameter is explicitly set to ``None``, the + MIMEText object created will have both a :mailheader:`Content-Type` header + with a ``charset`` parameter, and a :mailheader:`Content-Transfer-Endcoding` + header. This means that a subsequent ``set_payload`` call will not result + in an encoded payload, even if a charset is passed in the ``set_payload`` + command. You can "reset" this behavior by deleting the + ``Content-Transfer-Encoding`` header, after which a ``set_payload`` call + will automatically encode the new payload (and add a new + :mailheader:`Content-Transfer-Encoding` header). -