Skip to content

Commit 384f361

Browse files
Update docstrings.
1 parent 129d3dd commit 384f361

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

Lib/base64.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ def b64encode(s, altchars=None, *, padded=True, wrapcol=0):
5353
alternative alphabet for the '+' and '/' characters. This allows an
5454
application to e.g. generate url or filesystem safe Base64 strings.
5555
56+
If padded is false, omit padding in the output.
57+
5658
If wrapcol is non-zero, insert a newline (b'\\n') character after at most
5759
every wrapcol characters.
5860
"""
@@ -73,6 +75,8 @@ def b64decode(s, altchars=None, validate=_NOT_SPECIFIED,
7375
which specifies the alternative alphabet used instead of the '+' and '/'
7476
characters.
7577
78+
If padded is false, padding in input is not required.
79+
7680
The result is returned as a bytes object. A binascii.Error is raised if
7781
s is incorrectly padded.
7882
@@ -152,6 +156,8 @@ def urlsafe_b64encode(s, *, padded=True):
152156
Argument s is a bytes-like object to encode. The result is returned as a
153157
bytes object. The alphabet uses '-' instead of '+' and '_' instead of
154158
'/'.
159+
160+
If padded is false, omit padding in the output.
155161
"""
156162
return binascii.b2a_base64(s, padded=padded, newline=False,
157163
alphabet=binascii.URLSAFE_BASE64_ALPHABET)
@@ -165,6 +171,8 @@ def urlsafe_b64decode(s, *, padded=False):
165171
alphabet, and are not a plus '+' or slash '/', are discarded prior to the
166172
padding check.
167173
174+
If padded is false, padding in input is not required.
175+
168176
The alphabet uses '-' instead of '+' and '_' instead of '/'.
169177
"""
170178
s = _bytes_from_decode_data(s)
@@ -188,6 +196,8 @@ def urlsafe_b64decode(s, *, padded=False):
188196
_B32_ENCODE_DOCSTRING = '''
189197
Encode the bytes-like objects using {encoding} and return a bytes object.
190198
199+
If padded is false, omit padding in the output.
200+
191201
If wrapcol is non-zero, insert a newline (b'\\n') character after at most
192202
every wrapcol characters.
193203
'''
@@ -197,6 +207,8 @@ def urlsafe_b64decode(s, *, padded=False):
197207
Optional casefold is a flag specifying whether a lowercase alphabet is
198208
acceptable as input. For security purposes, the default is False.
199209
210+
If padded is false, padding in input is not required.
211+
200212
ignorechars should be a byte string containing characters to ignore
201213
from the input.
202214
{extra_args}

Modules/binascii.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ binascii.a2b_base64
724724
not allowed. The same applies to excess data after padding (= / ==).
725725
Set to True by default if ignorechars is specified, False otherwise.
726726
padded: bool = True
727+
When set to false, padding in input is not required.
727728
alphabet: PyBytesObject(c_default="NULL") = BASE64_ALPHABET
728729
ignorechars: Py_buffer = NULL
729730
A byte string containing characters to ignore from the input when
@@ -736,7 +737,7 @@ static PyObject *
736737
binascii_a2b_base64_impl(PyObject *module, Py_buffer *data, int strict_mode,
737738
int padded, PyBytesObject *alphabet,
738739
Py_buffer *ignorechars)
739-
/*[clinic end generated code: output=525d840a299ff132 input=d2d22b68a527a1db]*/
740+
/*[clinic end generated code: output=525d840a299ff132 input=74a53dd3b23474b3]*/
740741
{
741742
assert(data->len >= 0);
742743

@@ -924,6 +925,7 @@ binascii.b2a_base64
924925
/
925926
*
926927
padded: bool = True
928+
When set to false, omit padding in the output.
927929
wrapcol: size_t = 0
928930
newline: bool = True
929931
alphabet: Py_buffer(c_default="{NULL, NULL}") = BASE64_ALPHABET
@@ -934,7 +936,7 @@ Base64-code line of data.
934936
static PyObject *
935937
binascii_b2a_base64_impl(PyObject *module, Py_buffer *data, int padded,
936938
size_t wrapcol, int newline, Py_buffer *alphabet)
937-
/*[clinic end generated code: output=a2057b906dc201ab input=3b2f528e4eaa3bdb]*/
939+
/*[clinic end generated code: output=a2057b906dc201ab input=cfa33ad73051d3f7]*/
938940
{
939941
const unsigned char *table_b2a = table_b2a_base64;
940942
const unsigned char *bin_data = data->buf;
@@ -1528,6 +1530,7 @@ binascii.a2b_base32
15281530
/
15291531
*
15301532
padded: bool = True
1533+
When set to false, padding in input is not required.
15311534
alphabet: PyBytesObject(c_default="NULL") = BASE32_ALPHABET
15321535
ignorechars: Py_buffer = b''
15331536
A byte string containing characters to ignore from the input.
@@ -1538,7 +1541,7 @@ Decode a line of base32 data.
15381541
static PyObject *
15391542
binascii_a2b_base32_impl(PyObject *module, Py_buffer *data, int padded,
15401543
PyBytesObject *alphabet, Py_buffer *ignorechars)
1541-
/*[clinic end generated code: output=7dbbaa816d956b1c input=88edb4e84a5988c5]*/
1544+
/*[clinic end generated code: output=7dbbaa816d956b1c input=07a3721acdf9b688]*/
15421545
{
15431546
const unsigned char *ascii_data = data->buf;
15441547
Py_ssize_t ascii_len = data->len;
@@ -1734,6 +1737,7 @@ binascii.b2a_base32
17341737
/
17351738
*
17361739
padded: bool = True
1740+
When set to false, omit padding in the output.
17371741
wrapcol: size_t = 0
17381742
alphabet: Py_buffer(c_default="{NULL, NULL}") = BASE32_ALPHABET
17391743
@@ -1743,7 +1747,7 @@ Base32-code line of data.
17431747
static PyObject *
17441748
binascii_b2a_base32_impl(PyObject *module, Py_buffer *data, int padded,
17451749
size_t wrapcol, Py_buffer *alphabet)
1746-
/*[clinic end generated code: output=acc09e685569aab9 input=c3c0bb816fb5bd75]*/
1750+
/*[clinic end generated code: output=acc09e685569aab9 input=1889b0c497a1d3c2]*/
17471751
{
17481752
const unsigned char *table_b2a = table_b2a_base32;
17491753
const unsigned char *bin_data = data->buf;

Modules/clinic/binascii.c.h

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

0 commit comments

Comments
 (0)