From: Martin Panter Date: Wed, 24 Feb 2016 01:08:43 +0000 (+0000) Subject: Issue #22088: Merge base64 docs from 3.5 X-Git-Tag: v3.6.0a1~580 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=150ea1a1dffd624b4cd6c2608ece249d12588907;p=python Issue #22088: Merge base64 docs from 3.5 --- 150ea1a1dffd624b4cd6c2608ece249d12588907 diff --cc Lib/base64.py index eb925cd4c5,e2c597b0ca..ab3b1bf224 --- a/Lib/base64.py +++ b/Lib/base64.py @@@ -49,16 -49,14 +49,13 @@@ def _bytes_from_decode_data(s) # Base64 encoding/decoding uses binascii def b64encode(s, altchars=None): - """Encode a byte string using Base64. + """Encode the bytes-like object s using Base64 and return a bytes object. - s is the byte string to encode. Optional altchars must be a byte - string of length 2 which specifies an alternative alphabet for the - '+' and '/' characters. This allows an application to - e.g. generate url or filesystem safe Base64 strings. - - The encoded byte string is returned. + Optional altchars should be a byte string of length 2 which specifies an + alternative alphabet for the '+' and '/' characters. This allows an + application to e.g. generate url or filesystem safe Base64 strings. """ - # 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))