summaryrefslogtreecommitdiffstats
path: root/Lib/email/encoders.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2013-02-09 18:02:58 (GMT)
committerR David Murray <rdmurray@bitdance.com>2013-02-09 18:02:58 (GMT)
commitceaa8b1d7557cf1550c16f8ae11ee9b118ef9a93 (patch)
tree0d40360708d62f6941b0d2865c7eecdaf1d7a12b /Lib/email/encoders.py
parentd489c7a0a3936cd4bbb746e6c3eac36bff38d74b (diff)
downloadcpython-ceaa8b1d7557cf1550c16f8ae11ee9b118ef9a93.zip
cpython-ceaa8b1d7557cf1550c16f8ae11ee9b118ef9a93.tar.gz
cpython-ceaa8b1d7557cf1550c16f8ae11ee9b118ef9a93.tar.bz2
#16564: Fix regression in use of encoders.encode_noop with binary data.
Diffstat (limited to 'Lib/email/encoders.py')
-rw-r--r--Lib/email/encoders.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/email/encoders.py b/Lib/email/encoders.py
index e5c099f..88b2f57 100644
--- a/Lib/email/encoders.py
+++ b/Lib/email/encoders.py
@@ -76,3 +76,9 @@ def encode_7or8bit(msg):
def encode_noop(msg):
"""Do nothing."""
+ # Well, not quite *nothing*: in Python3 we have to turn bytes into a string
+ # in our internal surrogateescaped form in order to keep the model
+ # consistent.
+ orig = msg.get_payload()
+ if not isinstance(orig, str):
+ msg.set_payload(orig.decode('ascii', 'surrogateescape'))