summaryrefslogtreecommitdiffstats
path: root/Lib/base64.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-10-11 09:01:02 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-10-11 09:01:02 (GMT)
commite84c97656899750a8e6b01bef2cfc01b31d60220 (patch)
treedf461163e3ade56701a5844d1b1b47e29c887f9f /Lib/base64.py
parent5df7fddc0c678f10ae6f9995c516dd7091fd6cbc (diff)
downloadcpython-e84c97656899750a8e6b01bef2cfc01b31d60220.zip
cpython-e84c97656899750a8e6b01bef2cfc01b31d60220.tar.gz
cpython-e84c97656899750a8e6b01bef2cfc01b31d60220.tar.bz2
Issue #25357: Add an optional newline paramer to binascii.b2a_base64().
base64.b64encode() uses it to avoid a memory copy.
Diffstat (limited to 'Lib/base64.py')
-rwxr-xr-xLib/base64.py3
1 files changed, 1 insertions, 2 deletions
diff --git a/Lib/base64.py b/Lib/base64.py
index 640f787..eb925cd 100755
--- a/Lib/base64.py
+++ b/Lib/base64.py
@@ -58,8 +58,7 @@ def b64encode(s, altchars=None):
The encoded byte string is returned.
"""
- # Strip off the trailing newline
- encoded = binascii.b2a_base64(s)[:-1]
+ encoded = binascii.b2a_base64(s, newline=False)
if altchars is not None:
assert len(altchars) == 2, repr(altchars)
return encoded.translate(bytes.maketrans(b'+/', altchars))