diff options
author | R David Murray <rdmurray@bitdance.com> | 2013-08-22 01:10:31 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2013-08-22 01:10:31 (GMT) |
commit | 00ae435deef434f471e39bea3f3ab3a3e3cd90fe (patch) | |
tree | ec2589f471e6ee602b6bdf169c87db706ddd1a8c /Lib/email/message.py | |
parent | 0b169125caf768b2dce97537d10470b3fdee9ec9 (diff) | |
download | cpython-00ae435deef434f471e39bea3f3ab3a3e3cd90fe.zip cpython-00ae435deef434f471e39bea3f3ab3a3e3cd90fe.tar.gz cpython-00ae435deef434f471e39bea3f3ab3a3e3cd90fe.tar.bz2 |
#18324: set_payload now correctly handles binary input.
This also backs out the previous fixes for for #14360, #1717, and #16564.
Those bugs were actually caused by the fact that set_payload didn't decode to
str, thus rendering the model inconsistent. This fix does mean the data
processed by the encoder functions goes through an extra encode/decode cycle,
but it means the model is always consistent. Future API updates will provide
a better way to encode payloads, which will bypass this minor de-optimization.
Tests by Vajrasky Kok.
Diffstat (limited to 'Lib/email/message.py')
-rw-r--r-- | Lib/email/message.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/email/message.py b/Lib/email/message.py index 3feab52..5020a03 100644 --- a/Lib/email/message.py +++ b/Lib/email/message.py @@ -275,6 +275,8 @@ class Message: Optional charset sets the message's default character set. See set_charset() for details. """ + if isinstance(payload, bytes): + payload = payload.decode('ascii', 'surrogateescape') self._payload = payload if charset is not None: self.set_charset(charset) |