Skip to content

Commit 37df735

Browse files
Harmonize documentation.
1 parent 30f54a1 commit 37df735

File tree

4 files changed

+54
-45
lines changed

4 files changed

+54
-45
lines changed

Doc/library/base64.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,9 @@ Refer to the documentation of the individual functions for more information.
247247
after at most every *wrapcol* characters.
248248
If *wrapcol* is zero (default), do not insert any newlines.
249249

250-
*pad* controls whether the input is padded to a multiple of 4
251-
before encoding. Note that the ``btoa`` implementation always pads.
250+
If *pad* is true, the input is padded with ``b'\0'`` so its length is a
251+
multiple of 4 bytes before encoding.
252+
Note that the ``btoa`` implementation always pads.
252253

253254
*adobe* controls whether the encoded byte sequence is framed with ``<~``
254255
and ``~>``, which is used by the Adobe implementation.
@@ -268,8 +269,9 @@ Refer to the documentation of the individual functions for more information.
268269
*adobe* controls whether the input sequence is in Adobe Ascii85 format
269270
(i.e. is framed with <~ and ~>).
270271

271-
*ignorechars* should be a byte string containing characters to ignore
272-
from the input. This should only contain whitespace characters, and by
272+
*ignorechars* should be a :term:`bytes-like object` containing characters
273+
to ignore from the input.
274+
This should only contain whitespace characters, and by
273275
default contains all whitespace characters in ASCII.
274276

275277
.. versionadded:: 3.4

Doc/library/binascii.rst

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -109,38 +109,41 @@ The :mod:`binascii` module defines the following functions:
109109
accepted as a short form of the group ``!!!!!``, which encodes four
110110
consecutive null bytes.
111111

112-
If *foldspaces* is true, the special character ``y`` is also accepted as a
113-
short form of the group ``+<VdL``, which encodes four consecutive spaces.
114-
Note that neither short form is permitted if it occurs in the middle of
115-
another group.
112+
*foldspaces* is a flag that specifies whether the 'y' short sequence
113+
should be accepted as shorthand for 4 consecutive spaces (ASCII 0x20).
114+
This feature is not supported by the "standard" Ascii85 encoding.
116115

117-
If *ignorechars* is true, the input begins with ``<~`` and ends with ``~>``, as in
118-
the Adobe Ascii85 format.
116+
*adobe* controls whether the input sequence is in Adobe Ascii85 format
117+
(i.e. is framed with <~ and ~>).
119118

120-
*ignorechars* is an optional bytes-like object that specifies characters to
121-
ignore in the input.
119+
*ignorechars* should be a :term:`bytes-like object` containing characters
120+
to ignore from the input.
121+
This should only contain whitespace characters.
122122

123123
Invalid Ascii85 data will raise :exc:`binascii.Error`.
124124

125125
.. versionadded:: next
126126

127127

128-
.. function:: b2a_ascii85(data, /, *, foldspaces=False, adobe=False, wrapcol=0, pad=False)
128+
.. function:: b2a_ascii85(data, /, *, foldspaces=False, wrapcol=0, pad=False, adobe=False)
129129

130130
Convert binary data to a formatted sequence of ASCII characters in Ascii85
131131
coding. The return value is the converted data.
132132

133-
If *foldspaces* is true, four consecutive spaces are encoded as the
134-
special character ``y`` instead of the sequence ``+<VdL``.
133+
*foldspaces* is an optional flag that uses the special short sequence 'y'
134+
instead of 4 consecutive spaces (ASCII 0x20) as supported by 'btoa'. This
135+
feature is not supported by the "standard" Ascii85 encoding.
135136

136-
If *adobe* is true, the output begins with ``<~`` and ends with ``~>``, as
137-
in the Adobe Ascii85 format.
137+
If *wrapcol* is non-zero, insert a newline (``b'\n'``) character
138+
after at most every *wrapcol* characters.
139+
If *wrapcol* is zero (default), do not insert any newlines.
138140

139-
If *wrapcol* is provided and greater than 0, the output is split into lines
140-
of no more than the specified width separated by the ASCII newline
141-
character.
141+
If *pad* is true, the input is padded with ``b'\0'`` so its length is a
142+
multiple of 4 bytes before encoding.
143+
Note that the ``btoa`` implementation always pads.
142144

143-
If *pad* is true, the input is padded to a multiple of 4 before encoding.
145+
*adobe* controls whether the encoded byte sequence is framed with ``<~``
146+
and ``~>``, which is used by the Adobe implementation.
144147

145148
.. versionadded:: next
146149

@@ -150,12 +153,13 @@ The :mod:`binascii` module defines the following functions:
150153
Convert Base85 data back to binary and return the binary data.
151154
More than one line may be passed at a time.
152155

153-
Invalid Base85 data will raise :exc:`binascii.Error`.
154156
Valid Base85 data contains characters from the Base85 alphabet in groups
155157
of five (except for the final group, which may have from two to five
156158
characters). Each group encodes 32 bits of binary data in the range from
157159
``0`` to ``2 ** 32 - 1``, inclusive.
158160

161+
Invalid Base85 data will raise :exc:`binascii.Error`.
162+
159163
.. versionadded:: next
160164

161165

@@ -164,7 +168,8 @@ The :mod:`binascii` module defines the following functions:
164168
Convert binary data to a line of ASCII characters in Base85 coding.
165169
The return value is the converted line.
166170

167-
If *pad* is true, the input is padded to a multiple of 4 before encoding.
171+
If *pad* is true, the input is padded with ``b'\0'`` so its length is a
172+
multiple of 4 bytes before encoding.
168173

169174
.. versionadded:: next
170175

@@ -174,14 +179,15 @@ The :mod:`binascii` module defines the following functions:
174179
Convert Z85 data back to binary and return the binary data.
175180
More than one line may be passed at a time.
176181

177-
Invalid Z85 data will raise :exc:`binascii.Error`.
178182
Valid Z85 data contains characters from the Z85 alphabet in groups
179183
of five (except for the final group, which may have from two to five
180184
characters). Each group encodes 32 bits of binary data in the range from
181185
``0`` to ``2 ** 32 - 1``, inclusive.
182186

183187
See `Z85 specification <https://rfc.zeromq.org/spec/32/>`_ for more information.
184188

189+
Invalid Z85 data will raise :exc:`binascii.Error`.
190+
185191
.. versionadded:: next
186192

187193

@@ -190,7 +196,8 @@ The :mod:`binascii` module defines the following functions:
190196
Convert binary data to a line of ASCII characters in Z85 coding.
191197
The return value is the converted line.
192198

193-
If *pad* is true, the input is padded to a multiple of 4 before encoding.
199+
If *pad* is true, the input is padded with ``b'\0'`` so its length is a
200+
multiple of 4 bytes before encoding.
194201

195202
See `Z85 specification <https://rfc.zeromq.org/spec/32/>`_ for more information.
196203

Modules/binascii.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,20 +1014,20 @@ binascii.b2a_ascii85
10141014
*
10151015
foldspaces: bool = False
10161016
Emit 'y' as a short form encoding four spaces.
1017-
adobe: bool = False
1018-
Wrap result in '<~' and '~>' as in Adobe Ascii85.
10191017
wrapcol: size_t = 0
10201018
Split result into lines of provided width.
10211019
pad: bool = False
10221020
Pad input to a multiple of 4 before encoding.
1021+
adobe: bool = False
1022+
Wrap result in '<~' and '~>' as in Adobe Ascii85.
10231023
10241024
Ascii85-encode data.
10251025
[clinic start generated code]*/
10261026

10271027
static PyObject *
10281028
binascii_b2a_ascii85_impl(PyObject *module, Py_buffer *data, int foldspaces,
1029-
int adobe, size_t wrapcol, int pad)
1030-
/*[clinic end generated code: output=b0fb8c917ea1b563 input=1b64734fc9d29e9b]*/
1029+
size_t wrapcol, int pad, int adobe)
1030+
/*[clinic end generated code: output=5ce8fdee843073f4 input=791da754508c7d17]*/
10311031
{
10321032
const unsigned char *bin_data = data->buf;
10331033
Py_ssize_t bin_len = data->len;

Modules/clinic/binascii.c.h

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)