]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43125: Fix: return expected type (str), not original value (bytes) in email/base6...
authorGrégory Starck <g.starck@gmail.com>
Tue, 30 Mar 2021 08:37:37 +0000 (04:37 -0400)
committerGitHub <noreply@github.com>
Tue, 30 Mar 2021 08:37:37 +0000 (17:37 +0900)
Lib/email/base64mime.py
Lib/test/test_email/test_email.py
Misc/NEWS.d/next/Library/2021-02-07-19-13-30.bpo-43125.AqNoMa.rst [new file with mode: 0644]

index 17f0818f6caa81a42351035a0b6dfc866bbe9e5c..a7cc37365c6f9a1814067269fe07fa78a6f2fe50 100644 (file)
@@ -84,7 +84,7 @@ def body_encode(s, maxlinelen=76, eol=NL):
     in an email.
     """
     if not s:
-        return s
+        return ""
 
     encvec = []
     max_unencoded = maxlinelen * 3 // 4
index 044b93862a14eb33dfef4942532b211b7f1f91f9..720a63b4e48ff7cedfef92a3cacaa9f056e55278 100644 (file)
@@ -4261,7 +4261,7 @@ class TestBase64(unittest.TestCase):
 
     def test_encode(self):
         eq = self.assertEqual
-        eq(base64mime.body_encode(b''), b'')
+        eq(base64mime.body_encode(b''), '')
         eq(base64mime.body_encode(b'hello'), 'aGVsbG8=\n')
         # Test the binary flag
         eq(base64mime.body_encode(b'hello\n'), 'aGVsbG8K\n')
@@ -4292,7 +4292,6 @@ eHh4eCB4eHh4IA==\r
         eq(he('hello\nworld'), '=?iso-8859-1?b?aGVsbG8Kd29ybGQ=?=')
 
 
-
 class TestQuopri(unittest.TestCase):
     def setUp(self):
         # Set of characters (as byte integers) that don't need to be encoded
diff --git a/Misc/NEWS.d/next/Library/2021-02-07-19-13-30.bpo-43125.AqNoMa.rst b/Misc/NEWS.d/next/Library/2021-02-07-19-13-30.bpo-43125.AqNoMa.rst
new file mode 100644 (file)
index 0000000..4c4a583
--- /dev/null
@@ -0,0 +1 @@
+Return empty string if base64mime.body_encode receive empty bytes