10000 [3.10] gh-90717: Update the documentation for the altchars paremeter in base64 library (GH-94187) by zooba · Pull Request #99879 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.10] gh-90717: Update the documentation for the altchars paremeter in base64 library (GH-94187) #99879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-90717: Update the documentation for the altchars paremeter in base…
…64 library (GH-94187)
  • Loading branch information
dignissimus authored and zooba committed Nov 29, 2022
commit a0dcb33e0c6ed4198d5f0a6eb3b129a54af1dce1
19 changes: 11 additions & 8 deletions Doc/library/base64.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,23 @@ 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)

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.
Expand All @@ -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)

Expand Down
0