Index: Doc/library/email.message.rst |
=================================================================== |
--- Doc/library/email.message.rst (revision 85191) |
+++ Doc/library/email.message.rst (working copy) |
@@ -111,11 +111,19 @@ |
be decoded if this header's value is ``quoted-printable`` or ``base64``. |
If some other encoding is used, or :mailheader:`Content-Transfer-Encoding` |
header is missing, or if the payload has bogus base64 data, the payload is |
- returned as-is (undecoded). If the message is a multipart and the |
- *decode* flag is ``True``, then ``None`` is returned. The default for |
- *decode* is ``False``. |
+ returned as-is (undecoded). In all cases the returned value is binary |
+ data. If the message is a multipart and the *decode* flag is ``True``, |
+ then ``None`` is returned. |
+ When *decode* is ``False`` (the default) the body is returned as a string |
+ without decoding the :mailheader:`ContentTransferEncoding`. However, for |
+ a :mailheader:`ContentTransferEncoding` of 8bit, an attempt is made to |
+ decode the original bytes using the `charset` specified by the |
+ :mailheader:`Content-Type` header, using the `replace` error handler. If |
+ no `charset` is specified, or if the `charset` given is not recognized by |
+ the email package, the body is decoding using the default ASCII charset. |
+ |
.. method:: set_payload(payload, charset=None) |
Set the entire message object's payload to *payload*. It is the client's |
@@ -160,7 +168,11 @@ |
Note that in all cases, any envelope header present in the message is not |
included in the mapping interface. |
+ In a model generated from bytes, any header values that (in contravention |
+ of the RFCs) contain non-ASCII bytes will have those bytes transformed |
+ into '?' characters when the values are retrieved through this interface. |
+ |
.. method:: __len__() |
Return the total number of headers, including duplicates. |