[issue4770] binascii module, crazy error messages, unexpected behavior
flox
report at bugs.python.org
Mon Dec 14 22:25:25 CET 2009
flox <laxyf at yahoo.fr> added the comment:
> Are you sure that this patch is correct (which RFC says
> that quoted printable should use our raw-unicode-escape
> codec ?):
I am not sure of anything. It is an "educated guess" at the most.
Since 'base64' and 'x-uuencode' both use 'raw-unicode-escape'...
See longer excerpt below.
Index: Lib/email/message.py
===================================================================
--- Lib/email/message.py (revision 76839)
+++ Lib/email/message.py (working copy)
@@ -189,24 +189,26 @@
elif not isinstance(self._payload, list):
raise TypeError('Expected list, got %s' % type(self._payload))
else:
payload = self._payload[i]
if not decode:
return payload
# Decoded payloads always return bytes. XXX split this part
out into
# a new method called .get_decoded_payload().
if self.is_multipart():
return None
cte = self.get('content-transfer-encoding', '').lower()
if cte == 'quoted-printable':
+ if isinstance(payload, str):
+ payload = payload.encode('raw-unicode-escape')
return utils._qdecode(payload)
elif cte == 'base64':
try:
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'):
in_file = BytesIO(payload.encode('raw-unicode-escape'))
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4770>
_______________________________________
More information about the Python-bugs-list
mailing list