8000 gh-90717: Update the documentation for the altchars paremeter in base… · python/cpython@05dfc53 · GitHub
[go: up one dir, main page]

Skip to content

Commit 05dfc53

Browse files
authored
gh-90717: Update the documentation for the altchars paremeter in base64 library (GH-94187)
1 parent 74d5f61 commit 05dfc53

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

Doc/library/base64.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,23 @@ The modern interface provides:
5353
Encode the :term:`bytes-like object` *s* using Base64 and return the encoded
5454
:class:`bytes`.
5555

56-
Optional *altchars* must be a :term:`bytes-like object` of at least
57-
length 2 (additional characters are ignored) which specifies an alternative
58-
alphabet for the ``+`` and ``/`` characters. This allows an application to e.g.
59-
generate URL or filesystem safe Base64 strings. The default is ``None``, for
60-
which the standard Base64 alphabet is used.
56+
Optional *altchars* must be a :term:`bytes-like object` of length 2 which
57+
specifies an alternative alphabet for the ``+`` and ``/`` characters.
58+
This allows an application to e.g. generate URL or filesystem safe Base64
59+
strings. The default is ``None``, for which the standard Base64 alphabet is used.
60+
61+
May assert or raise a a :exc:`ValueError` if the length of *altchars* is not 2. Raises a
62+
:exc:`TypeError` if *altchars* is not a :term:`bytes-like object`.
6163

6264

6365
.. function:: b64decode(s, altchars=None, validate=False)
6466

6567
Decode the Base64 encoded :term:`bytes-like object` or ASCII string
6668
*s* and return the decoded :class:`bytes`.
6769

68-
Optional *altchars* must be a :term:`bytes-like object` or ASCII string of
69-
at least length 2 (additional characters are ignored) which specifies the
70-
alternative alphabet used instead of the ``+`` and ``/`` characters.
70+
Optional *altchars* must be a :term:`bytes-like object` or ASCII string
71+
of length 2 which specifies the alternative alphabet used instead of the
72+
``+`` and ``/`` characters.
7173

7274
A :exc:`binascii.Error` exception is raised
7375
if *s* is incorrectly padded.
@@ -80,6 +82,7 @@ The modern interface provides:
8082

8183
For more 5A09 information about the strict base64 check, see :func:`binascii.a2b_base64`
8284

85+
May assert or raise a :exc:`ValueError` if the length of *altchars* is not 2.
8386

8487
.. function:: standard_b64encode(s)
8588

0 commit comments

Comments
 (0)
0