summaryrefslogtreecommitdiff
path: root/Lib/email
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-08-09 15:34:58 -0700
committerGitHub <noreply@github.com>2021-08-10 00:34:58 +0200
commit395f4c7fbfb89b8724a4abf84410b5e1e374932d (patch)
tree9e79f9bc31ff28727913bed8ade2e42bb33bfa6c /Lib/email
parent40b353bc079b990cf0d6259a5720fb9729c1b81e (diff)
downloadcpython-git-395f4c7fbfb89b8724a4abf84410b5e1e374932d.tar.gz
bpo-41402: Fix email ContentManager calling .encode() on bytes (GH-21631) (GH-27687)
(cherry picked from commit b33186bc43bb5aaf652dd9d093a08fdde796d499) Co-authored-by: Johannes Reiff <mail@jreiff.de>
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/contentmanager.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/Lib/email/contentmanager.py b/Lib/email/contentmanager.py
index b91fb0e5bc..3cf62dc862 100644
--- a/Lib/email/contentmanager.py
+++ b/Lib/email/contentmanager.py
@@ -238,9 +238,7 @@ def set_bytes_content(msg, data, maintype, subtype, cte='base64',
data = binascii.b2a_qp(data, istext=False, header=False, quotetabs=True)
data = data.decode('ascii')
elif cte == '7bit':
- # Make sure it really is only ASCII. The early warning here seems
- # worth the overhead...if you care write your own content manager :).
- data.encode('ascii')
+ data = data.decode('ascii')
elif cte in ('8bit', 'binary'):
data = data.decode('ascii', 'surrogateescape')
msg.set_payload(data)