summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2013-02-09 18:10:54 (GMT)
committerR David Murray <rdmurray@bitdance.com>2013-02-09 18:10:54 (GMT)
commit6cb1d67eb3bd235e1d49eeb602f15f3d40a5e228 (patch)
treeac855e8de48da9928d9754b419991157be0d9cdb /Lib/email
parent7d01a1eb2b636891fcac90f48290293bc2b9f3eb (diff)
parentceaa8b1d7557cf1550c16f8ae11ee9b118ef9a93 (diff)
downloadcpython-6cb1d67eb3bd235e1d49eeb602f15f3d40a5e228.zip
cpython-6cb1d67eb3bd235e1d49eeb602f15f3d40a5e228.tar.gz
cpython-6cb1d67eb3bd235e1d49eeb602f15f3d40a5e228.tar.bz2
Merge: #16564: Fix regression in use of encoders.encode_noop with binary data.
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/encoders.py6
-rw-r--r--Lib/email/generator.py3
2 files changed, 9 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'))
diff --git a/Lib/email/generator.py b/Lib/email/generator.py
index 899adbc..de9da39 100644
--- a/Lib/email/generator.py
+++ b/Lib/email/generator.py
@@ -406,6 +406,9 @@ class BytesGenerator(Generator):
else:
super(BytesGenerator,self)._handle_text(msg)
+ # Default body handler
+ _writeBody = _handle_text
+
@classmethod
def _compile_re(cls, s, flags):
return re.compile(s.encode('ascii'), flags)