summaryrefslogtreecommitdiffstats
path: root/Lib/email/encoders.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2013-02-09 18:13:14 (GMT)
committerR David Murray <rdmurray@bitdance.com>2013-02-09 18:13:14 (GMT)
commitc9b4e60683975adf897c262c0d9d337db2f30449 (patch)
treec761124cd498bd218b221431f50f46859c8f22cb /Lib/email/encoders.py
parent633a92ff20fac830409faa91f0e5bc7ff03759df (diff)
parent6cb1d67eb3bd235e1d49eeb602f15f3d40a5e228 (diff)
downloadcpython-c9b4e60683975adf897c262c0d9d337db2f30449.zip
cpython-c9b4e60683975adf897c262c0d9d337db2f30449.tar.gz
cpython-c9b4e60683975adf897c262c0d9d337db2f30449.tar.bz2
Merge: #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'))