diff options
author | Steve Dower <steve.dower@python.org> | 2022-11-29 16:43:36 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-29 16:43:36 (GMT) |
commit | ca3c48072b8c2b21f3f08e2e87cc4152377695c6 (patch) | |
tree | d6973756425eabda131aaa38414851c6ece90b38 /Doc | |
parent | 1b43fa6890aea98e5108a6aed560ceee348b0a07 (diff) | |
download | cpython-ca3c48072b8c2b21f3f08e2e87cc4152377695c6.zip cpython-ca3c48072b8c2b21f3f08e2e87cc4152377695c6.tar.gz cpython-ca3c48072b8c2b21f3f08e2e87cc4152377695c6.tar.bz2 |
gh-90717: Update the documentation for the altchars paremeter in base64 library (GH-94187)
Co-authored-by: Sam Ezeh <sam.z.ezeh@gmail.com>
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/base64.rst | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/Doc/library/base64.rst b/Doc/library/base64.rst index f1063a7..694c166 100644 --- a/Doc/library/base64.rst +++ b/Doc/library/base64.rst @@ -53,11 +53,13 @@ The modern interface provides: Encode the :term:`bytes-like object` *s* using Base64 and return the encoded :class:`bytes`. - Optional *altchars* must be a :term:`bytes-like object` of at least - length 2 (additional characters are ignored) which specifies an alternative - alphabet for the ``+`` and ``/`` characters. This allows an application to e.g. - generate URL or filesystem safe Base64 strings. The default is ``None``, for - which the standard Base64 alphabet is used. + Optional *altchars* must be a :term:`bytes-like object` 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 default is ``None``, for which the standard Base64 alphabet is used. + + May assert or raise a a :exc:`ValueError` if the length of *altchars* is not 2. Raises a + :exc:`TypeError` if *altchars* is not a :term:`bytes-like object`. .. function:: b64decode(s, altchars=None, validate=False) @@ -65,9 +67,9 @@ The modern interface provides: Decode the Base64 encoded :term:`bytes-like object` or ASCII string *s* and return the decoded :class:`bytes`. - Optional *altchars* must be a :term:`bytes-like object` or ASCII string of - at least length 2 (additional characters are ignored) which specifies the - alternative alphabet used instead of the ``+`` and ``/`` characters. + Optional *altchars* must be a :term:`bytes-like object` or ASCII string + of length 2 which specifies the alternative alphabet used instead of the + ``+`` and ``/`` characters. A :exc:`binascii.Error` exception is raised if *s* is incorrectly padded. @@ -78,6 +80,7 @@ The modern interface provides: these non-alphabet characters in the input result in a :exc:`binascii.Error`. + May assert or raise a :exc:`ValueError` if the length of *altchars* is not 2. .. function:: standard_b64encode(s) |