mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Issue #25357: Add an optional newline paramer to binascii.b2a_base64().
base64.b64encode() uses it to avoid a memory copy.
This commit is contained in:
parent
5df7fddc0c
commit
e84c976568
6 changed files with 45 additions and 20 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue