FFFF #11216: document all possible set_charset execution paths. · python/cpython@e3d09ff · GitHub
[go: up one dir, main page]

Skip to content

Commit e3d09ff

Browse files
committed
#11216: document all possible set_charset execution paths.
1 parent 126848a commit e3d09ff

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

Doc/library/email.message.rst

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,22 @@ Here are the methods of the :class:`Message` class:
130130
string naming a character set, or ``None``. If it is a string, it will
131131
be converted to a :class:`~email.charset.Charset` instance. If *charset*
132132
is ``None``, the ``charset`` parameter will be removed from the
133-
:mailheader:`Content-Type` header. Anything else will generate a
134-
:exc:`TypeError`.
135-
136-
The message will be assumed to be of type :mimetype:`text/\*` encoded with
137-
*charset.input_charset*. It will be converted to *charset.output_charset*
138-
and encoded properly, if needed, when generating the plain text
139-
representation of the message. MIME headers (:mailheader:`MIME-Version`,
140-
:mailheader:`Content-Type`, :mailheader:`Content-Transfer-Encoding`) will
141-
be added as needed.
133+
:mailheader:`Content-Type` header (the message will not be otherwise
134+
modified). Anything else will generate a :exc:`TypeError`.
135+
136+
If there is no existing :mailheader:`MIME-Version` header one will be
137+
added. If there is no existing :mailheader:`< 88C9 span class="pl-mi">Content-Type` header, one
138+
will be added with a value of :mimetype:`text/plain`. Whether the
139+
:mailheader:`Content-Type` header already exists or not, its ``charset``
140+
parameter will be set to *charset.output_charset*. If
141+
*charset.input_charset* and *charset.output_charset* differ, the payload
142+
will be re-encoded to the *output_charset*. If there is no existing
143+
:mailheader:`Content-Transfer-Encoding` header, then the payload will be
144+
transfer-encoded, if needed, using the specified
145+
:class:`~email.charset.Charset`, and a header with the appropriate value
146+
will be added. If a :mailheader:`Content-Transfer-Encoding` header
147+
already exists, the payload is assumed to already be correctly encoded
148+
using that :mailheader:`Content-Transfer-Encoding` and is not modified.
142149

143150
.. method:: get_charset()
144151

0 commit comments

Comments
 (0)
0