Skip to content

Commit cf35e05

Browse files
authored
bpo-43125: Fix: return expected type (str), not original value (bytes) in email/base64mime.py::body_encode (pythonGH-24476)
1 parent dfeec34 commit cf35e05

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

Lib/email/base64mime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def body_encode(s, maxlinelen=76, eol=NL):
8484
in an email.
8585
"""
8686
if not s:
87-
return s
87+
return ""
8888

8989
encvec = []
9090
max_unencoded = maxlinelen * 3 // 4

Lib/test/test_email/test_email.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4261,7 +4261,7 @@ def test_decode(self):
42614261

42624262
def test_encode(self):
42634263
eq = self.assertEqual
4264-
eq(base64mime.body_encode(b''), b'')
4264+
eq(base64mime.body_encode(b''), '')
42654265
eq(base64mime.body_encode(b'hello'), 'aGVsbG8=\n')
42664266
# Test the binary flag
42674267
eq(base64mime.body_encode(b'hello\n'), 'aGVsbG8K\n')
@@ -4292,7 +4292,6 @@ def test_header_encode(self):
42924292
eq(he('hello\nworld'), '=?iso-8859-1?b?aGVsbG8Kd29ybGQ=?=')
42934293

42944294

4295-
42964295
class TestQuopri(unittest.TestCase):
42974296
def setUp(self):
42984297
# Set of characters (as byte integers) that don't need to be encoded
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Return empty string if base64mime.body_encode receive empty bytes

0 commit comments

Comments
 (0)