Index: Lib/email/test/test_email_renamed.py =================================================================== --- Lib/email/test/test_email_renamed.py (revision 78650) +++ Lib/email/test/test_email_renamed.py (working copy) @@ -194,8 +194,11 @@ # Subpart 3 is base64 eq(msg.get_payload(2).get_payload(decode=True), 'This is a Base64 encoded message.') - # Subpart 4 has no Content-Transfer-Encoding: header. + # Subpart 4 is also base64 eq(msg.get_payload(3).get_payload(decode=True), + 'This is a Base64 encoded message.\n') + # Subpart 5 has no Content-Transfer-Encoding: header. + eq(msg.get_payload(4).get_payload(decode=True), 'This has no Content-Transfer-Encoding: header.\n') def test_get_decoded_uu_payload(self): Index: Lib/email/test/data/msg_10.txt =================================================================== --- Lib/email/test/data/msg_10.txt (revision 78650) +++ Lib/email/test/data/msg_10.txt (working copy) @@ -26,7 +26,14 @@ --BOUNDARY Content-Type: text/plain; charset="iso-8859-1" +Content-Transfer-Encoding: Base64 +VGhpcyBpcyBhIEJhc2U2NCBlbmNvZGVkIG1lc3NhZ2UuCg== + + +--BOUNDARY +Content-Type: text/plain; charset="iso-8859-1" + This has no Content-Transfer-Encoding: header. --BOUNDARY-- Index: Lib/email/test/test_email.py =================================================================== --- Lib/email/test/test_email.py (revision 78650) +++ Lib/email/test/test_email.py (working copy) @@ -205,8 +205,11 @@ # Subpart 3 is base64 eq(msg.get_payload(2).get_payload(decode=True), 'This is a Base64 encoded message.') - # Subpart 4 has no Content-Transfer-Encoding: header. + # Subpart 4 is base64 eq(msg.get_payload(3).get_payload(decode=True), + 'This is a Base64 encoded message.\n') + # Subpart 5 has no Content-Transfer-Encoding: header. + eq(msg.get_payload(4).get_payload(decode=True), 'This has no Content-Transfer-Encoding: header.\n') def test_get_decoded_uu_payload(self): Index: Lib/email/utils.py =================================================================== --- Lib/email/utils.py (revision 78650) +++ Lib/email/utils.py (working copy) @@ -60,14 +60,15 @@ def _bdecode(s): - # We can't quite use base64.encodestring() since it tacks on a "courtesy - # newline". Blech! + """Decodes a base64 string. + + This function is equivalent to base64.decodestring and it's retained only + for backward compatibility. It used to remove the last \n of the decoded + string, if it had any. + """ if not s: return s - value = base64.decodestring(s) - if not s.endswith('\n') and value.endswith('\n'): - return value[:-1] - return value + return base64.decodestring(s)