diff options
author | 2022-11-29 08:29:03 -0800 | |
---|---|---|
committer | 2022-11-29 08:29:03 -0800 | |
commit | 2e9ea7b44b322c7353516acc6ef4737acc86d07a (patch) | |
tree | 864195ee08c1cd76ffae7292d7065d6942a8e6f7 | |
parent | gh-99344, gh-99379, gh-99382: Fix issues in substitution of ParamSpec and Typ... (diff) | |
download | cpython-2e9ea7b44b322c7353516acc6ef4737acc86d07a.tar.gz cpython-2e9ea7b44b322c7353516acc6ef4737acc86d07a.tar.bz2 cpython-2e9ea7b44b322c7353516acc6ef4737acc86d07a.zip |
gh-90717: Update the documentation for the altchars paremeter in base64 library (GH-94187)
(cherry picked from commit 05dfc539c2de34021e44f621f2b7b993682ee200)
Co-authored-by: Sam Ezeh <sam.z.ezeh@gmail.com>
-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 a02ba73914..4ca3768f82 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. @@ -80,6 +82,7 @@ The modern interface provides: For more information about the strict base64 check, see :func:`binascii.a2b_base64` + May assert or raise a :exc:`ValueError` if the length of *altchars* is not 2. .. function:: standard_b64encode(s) |