Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 90cb105

Browse files
committed
Merge: #1525919: Document MIMEText+set_payload encoding behavior.
2 parents 04e6590 + 432a48a commit 90cb105

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Doc/library/email.mime.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,13 @@ Here are the classes:
187187
:class:`~email.mime.nonmultipart.MIMENonMultipart` constructor; it defaults
188188
to ``us-ascii`` if the string contains only ``ascii`` codepoints, and
189189
``utf-8`` otherwise.
190+
191+
Unless the ``_charset`` parameter is explicitly set to ``None``, the
192+
MIMEText object created will have both a :mailheader:`Content-Type` header
193+
with a ``charset`` parameter, and a :mailheader:`Content-Transfer-Endcoding`
194+
header. This means that a subsequent ``set_payload`` call will not result
195+
in an encoded payload, even if a charset is passed in the ``set_payload``
196+
command. You can "reset" this behavior by deleting the
197+
``Content-Transfer-Encoding`` header, after which a ``set_payload`` call
198+
will automatically encode the new payload (and add a new
199+
:mailheader:`Content-Transfer-Encoding` header).

0 commit comments

Comments
 (0)