Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Address review comment.
  • Loading branch information
serhiy-storchaka committed Dec 31, 2025
commit bd3ed763560b10b4dfe993466cb0d94053d2064e
18 changes: 7 additions & 11 deletions Doc/library/base64.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,13 @@ POST request.
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.

If *wrapcol* is non-zero, insert a newline (``b'\n'``) character
after at most every *wrapcol* characters.
If *wrapcol* is zero (default), do not add any newlines.

May assert or raise a :exc:`ValueError` if the length of *altchars* is not 2. Raises a
:exc:`TypeError` if *altchars* is not a :term:`bytes-like object`.

If *wrapcol* is non-zero, the output will be represented in lines of
no more than *wrapcol* characters each, separated by a newline
(``b'\n'``) character.
If *wrapcol* is zero (default), the output will be represented as
a single line.

.. versionchanged:: next
Added the *wrapcol* parameter.

Expand Down Expand Up @@ -223,11 +221,9 @@ Refer to the documentation of the individual functions for more information.
instead of 4 consecutive spaces (ASCII 0x20) as supported by 'btoa'. This
feature is not supported by the "standard" Ascii85 encoding.

If *wrapcol* is non-zero, the output will be represented in lines of
no more than *wrapcol* characters each, separated by a newline
(``b'\n'``) character.
If *wrapcol* is zero (default), the output will be represented as
a single line.
If *wrapcol* is non-zero, insert a newline (``b'\n'``) character
after at most every *wrapcol* characters.
If *wrapcol* is zero (default), do not add any newlines.

*pad* controls whether the input is padded to a multiple of 4
before encoding. Note that the ``btoa`` implementation always pads.
Expand Down
8 changes: 3 additions & 5 deletions Doc/library/binascii.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,9 @@ The :mod:`binascii` module defines the following functions:
Convert binary data to a line(s) of ASCII characters in base64 coding,
as specified in :rfc:`4648`.

If *wrapcol* is non-zero, the output will be represented in lines of
no more than *wrapcol* characters each, separated by a newline
(``b'\n'``) character.
If *wrapcol* is zero (default), the output will be represented as
a single line.
If *wrapcol* is non-zero, insert a newline (``b'\n'``) character
after at most every *wrapcol* characters.
If *wrapcol* is zero (default), do not add any newlines.

If *newline* is true (default), a newline character will be added
at the end of the output.
Expand Down
10 changes: 4 additions & 6 deletions Lib/base64.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ def b64encode(s, altchars=None, *, wrapcol=0):
alternative alphabet for the '+' and '/' characters. This allows an
application to e.g. generate url or filesystem safe Base64 strings.

If wrapcol is non-zero, the output will be represented in lines of
no more than wrapcol characters each, separated by a newline (b'\\n')
character.
If wrapcol is non-zero, insert a newline (b'\\n') character after at most
every wrapcol characters.
"""
encoded = binascii.b2a_base64(s, wrapcol=wrapcol, newline=False)
if altchars is not None:
Expand Down Expand Up @@ -331,9 +330,8 @@ def a85encode(b, *, foldspaces=False, wrapcol=0, pad=False, adobe=False):
instead of 4 consecutive spaces (ASCII 0x20) as supported by 'btoa'. This
feature is not supported by the "standard" Adobe encoding.

If wrapcol is non-zero, the output will be represented in lines of
no more than wrapcol characters each, separated by a newline (b'\\n')
character.
If wrapcol is non-zero, insert a newline (b'\\n') character after at most
every wrapcol characters.

pad controls whether the input is padded to a multiple of 4 before
encoding. Note that the btoa implementation always pads.
Expand Down