mirror of
https://github.com/python/cpython.git
synced 2025-08-01 15:43:13 +00:00
bpo-43125: Fix: return expected type (str), not original value (bytes) in email/base64mime.py::body_encode (GH-24476)
This commit is contained in:
parent
dfeec347f2
commit
cf35e05f89
3 changed files with 3 additions and 3 deletions
|
@ -84,7 +84,7 @@ def body_encode(s, maxlinelen=76, eol=NL):
|
||||||
in an email.
|
in an email.
|
||||||
"""
|
"""
|
||||||
if not s:
|
if not s:
|
||||||
return s
|
return ""
|
||||||
|
|
||||||
encvec = []
|
encvec = []
|
||||||
max_unencoded = maxlinelen * 3 // 4
|
max_unencoded = maxlinelen * 3 // 4
|
||||||
|
|
|
@ -4261,7 +4261,7 @@ class TestBase64(unittest.TestCase):
|
||||||
|
|
||||||
def test_encode(self):
|
def test_encode(self):
|
||||||
eq = self.assertEqual
|
eq = self.assertEqual
|
||||||
eq(base64mime.body_encode(b''), b'')
|
eq(base64mime.body_encode(b''), '')
|
||||||
eq(base64mime.body_encode(b'hello'), 'aGVsbG8=\n')
|
eq(base64mime.body_encode(b'hello'), 'aGVsbG8=\n')
|
||||||
# Test the binary flag
|
# Test the binary flag
|
||||||
eq(base64mime.body_encode(b'hello\n'), 'aGVsbG8K\n')
|
eq(base64mime.body_encode(b'hello\n'), 'aGVsbG8K\n')
|
||||||
|
@ -4292,7 +4292,6 @@ eHh4eCB4eHh4IA==\r
|
||||||
eq(he('hello\nworld'), '=?iso-8859-1?b?aGVsbG8Kd29ybGQ=?=')
|
eq(he('hello\nworld'), '=?iso-8859-1?b?aGVsbG8Kd29ybGQ=?=')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestQuopri(unittest.TestCase):
|
class TestQuopri(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
# Set of characters (as byte integers) that don't need to be encoded
|
# Set of characters (as byte integers) that don't need to be encoded
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Return empty string if base64mime.body_encode receive empty bytes
|
Loading…
Add table
Add a link
Reference in a new issue