diff options
author | R. David Murray <rdmurray@bitdance.com> | 2010-11-11 20:09:20 (GMT) |
---|---|---|
committer | R. David Murray <rdmurray@bitdance.com> | 2010-11-11 20:09:20 (GMT) |
commit | 6495136e4018b626c40500bbd564fdfda9825587 (patch) | |
tree | 3d49ba6a59663e6cff25a7f5f16942b7c5c8a3b0 /Doc/library/base64.rst | |
parent | 49afa380fd86dfa07e68e7838adcdad38d3d8ba6 (diff) | |
download | cpython-6495136e4018b626c40500bbd564fdfda9825587.zip cpython-6495136e4018b626c40500bbd564fdfda9825587.tar.gz cpython-6495136e4018b626c40500bbd564fdfda9825587.tar.bz2 |
#1466065: add validate option to base64.b64decode
Patch by Neil Tallim. This provides a mechanism for module
users to achieve RFC 3548 compliance in the cases where ignoring
non-base64-alphabet input characters is *not* mandated by the RFC that
references RFC 3548.
Diffstat (limited to 'Doc/library/base64.rst')
-rw-r--r-- | Doc/library/base64.rst | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Doc/library/base64.rst b/Doc/library/base64.rst index c10a74a..2401ae7 100644 --- a/Doc/library/base64.rst +++ b/Doc/library/base64.rst @@ -37,7 +37,7 @@ The modern interface provides: The encoded byte string is returned. -.. function:: b64decode(s, altchars=None) +.. function:: b64decode(s, altchars=None, validate=False) Decode a Base64 encoded byte string. @@ -45,9 +45,13 @@ The modern interface provides: at least length 2 (additional characters are ignored) which specifies the alternative alphabet used instead of the ``+`` and ``/`` characters. - The decoded byte string is returned. A :exc:`TypeError` is raised if *s* were - incorrectly padded or if there are non-alphabet characters present in the - string. + The decoded string is returned. A `binascii.Error` is raised if *s* is + incorrectly padded. + + If *validate* is ``False`` (the default), non-base64-alphabet characters are + discarded prior to the padding check. If *validate* is ``True``, + non-base64-alphabet characters in the input result in a + :exc:`binascii.Error`. .. function:: standard_b64encode(s) |