summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorAlexandre Vassalotti <alexandre@peadrop.com>2008-05-03 04:39:38 (GMT)
committerAlexandre Vassalotti <alexandre@peadrop.com>2008-05-03 04:39:38 (GMT)
commit5209857f8ef14876e03a3d7445bdad9b8de51faf (patch)
tree8e0393d0d42d9334b17295b531cc70ea263a9dae /Lib/email
parent8cb02b6000c66478406c12270a9f86e39fd20305 (diff)
downloadcpython-5209857f8ef14876e03a3d7445bdad9b8de51faf.zip
cpython-5209857f8ef14876e03a3d7445bdad9b8de51faf.tar.gz
cpython-5209857f8ef14876e03a3d7445bdad9b8de51faf.tar.bz2
Removed implicit convertions of str object to bytes from base64.
This also exposed some bugs in urlib2 and email.base64mime, which I tried my best to fix. However, someone will probably have to double check.
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/base64mime.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/email/base64mime.py b/Lib/email/base64mime.py
index c60f8db..6db007d 100644
--- a/Lib/email/base64mime.py
+++ b/Lib/email/base64mime.py
@@ -66,9 +66,10 @@ def header_encode(header_bytes, charset='iso-8859-1'):
charset names the character set to use to encode the header. It defaults
to iso-8859-1. Base64 encoding is defined in RFC 2045.
"""
- # Return empty headers unchanged
if not header_bytes:
- return str(header_bytes)
+ return ""
+ if isinstance(header_bytes, str):
+ header_bytes = header_bytes.encode(charset)
encoded = b64encode(header_bytes).decode("ascii")
return '=?%s?b?%s?=' % (charset, encoded)