Skip to content

Commit a398754

Browse files
gh-144027: Fix documentation for ignorechars in base64.a85decode()
It does not support an ASCII string. Also add more tests.
1 parent 63cc125 commit a398754

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Doc/library/base64.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,7 @@ Refer to the documentation of the individual functions for more information.
246246
*adobe* controls whether the input sequence is in Adobe Ascii85 format
247247
(i.e. is framed with <~ and ~>).
248248

249-
*ignorechars* should be a :term:`bytes-like object` or ASCII string
250-
containing characters to ignore
249+
*ignorechars* should be a byte string containing characters to ignore
251250
from the input. This should only contain whitespace characters, and by
252251
default contains all whitespace characters in ASCII.
253252

Lib/test/test_base64.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,19 @@ def test_a85decode_errors(self):
948948
self.assertRaises(ValueError, base64.a85decode, b'aaaay',
949949
foldspaces=True)
950950

951+
self.assertEqual(base64.a85decode(b"a b\nc", ignorechars=b" \n"),
952+
b'\xc9\x89')
953+
with self.assertRaises(ValueError):
954+
base64.a85decode(b"a b\nc", ignorechars=b"")
955+
with self.assertRaises(ValueError):
956+
base64.a85decode(b"a b\nc", ignorechars=b" ")
957+
with self.assertRaises(ValueError):
958+
base64.a85decode(b"a b\nc", ignorechars=b"\n")
959+
with self.assertRaises(TypeError):
960+
base64.a85decode(b"a b\nc", ignorechars=" \n")
961+
with self.assertRaises(TypeError):
962+
base64.a85decode(b"a b\nc", ignorechars=None)
963+
951964
def test_b85decode_errors(self):
952965
illegal = list(range(33)) + \
953966
list(b'"\',./:[\\]') + \

0 commit comments

Comments
 (0)