[Python-checkins] cpython (3.2): #1525919: Document MIMEText+set_payload encoding behavior.

r.david.murray python-checkins at python.org
Tue Mar 19 23:22:03 CET 2013


http://hg.python.org/cpython/rev/ba500b179c3a
changeset:   82783:ba500b179c3a
branch:      3.2
parent:      82773:33f02ccb5301
user:        R David Murray <rdmurray at bitdance.com>
date:        Tue Mar 19 18:18:55 2013 -0400
summary:
  #1525919: Document MIMEText+set_payload encoding behavior.

files:
  Doc/library/email.mime.rst |  12 +++++++++++-
  1 files changed, 11 insertions(+), 1 deletions(-)


diff --git a/Doc/library/email.mime.rst b/Doc/library/email.mime.rst
--- a/Doc/library/email.mime.rst
+++ b/Doc/library/email.mime.rst
@@ -185,5 +185,15 @@
    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``.  No guessing or encoding is performed on the text data.
+   to ``us-ascii``.
 
+   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).
+

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list