summaryrefslogtreecommitdiffstats
path: root/Lib/email/message.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2007-08-31 03:04:26 (GMT)
committerBarry Warsaw <barry@python.org>2007-08-31 03:04:26 (GMT)
commit8b2af27dae7c80218c9912052ac1b4c6144ce746 (patch)
tree5dca10b0aa0f7ee88bd3e8eb2f303d994674058d /Lib/email/message.py
parent00b34228bb98c378286c0b72a4a4098d5cdd384b (diff)
downloadcpython-8b2af27dae7c80218c9912052ac1b4c6144ce746.zip
cpython-8b2af27dae7c80218c9912052ac1b4c6144ce746.tar.gz
cpython-8b2af27dae7c80218c9912052ac1b4c6144ce746.tar.bz2
More email package fixes.
MIMEApplication() requires a bytes object for its _data, so fix the tests. We no longer need utils._identity() or utils._bdecode(). The former isn't used anywhere AFAICT (where's "make test's" lint? <wink>) and the latter is a kludge that is eliminated by base64.b64encode(). Current status: 5F/5E
Diffstat (limited to 'Lib/email/message.py')
-rw-r--r--Lib/email/message.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/email/message.py b/Lib/email/message.py
index e368737..ff262c7 100644
--- a/Lib/email/message.py
+++ b/Lib/email/message.py
@@ -8,6 +8,7 @@ __all__ = ['Message']
import re
import uu
+import base64
import binascii
import warnings
from io import BytesIO, StringIO
@@ -196,12 +197,14 @@ class Message:
return utils._qdecode(payload)
elif cte == 'base64':
try:
- return utils._bdecode(payload)
+ if isinstance(payload, str):
+ payload = payload.encode('raw-unicode-escape')
+ return base64.b64decode(payload)
+ #return utils._bdecode(payload)
except binascii.Error:
# Incorrect padding
pass
elif cte in ('x-uuencode', 'uuencode', 'uue', 'x-uue'):
- payload += '\n'
in_file = BytesIO(payload.encode('raw-unicode-escape'))
out_file = BytesIO()
try:
@@ -212,7 +215,9 @@ class Message:
pass
# Is there a better way to do this? We can't use the bytes
# constructor.
- return bytes(payload, 'raw-unicode-escape')
+ if isinstance(payload, str):
+ return payload.encode('raw-unicode-escape')
+ return payload
def set_payload(self, payload, charset=None):
"""Set the payload to the given value.