Skip to content

Commit 25a10b6

Browse files
gh-144027: Fix documentation for ignorechars in base64.a85decode() (GH-144028)
It does not support an ASCII string. Also add more tests.
1 parent 2f42f83 commit 25a10b6

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
@@ -254,8 +254,7 @@ Refer to the documentation of the individual functions for more information.
254254
*adobe* controls whether the input sequence is in Adobe Ascii85 format
255255
(i.e. is framed with <~ and ~>).
256256

257-
*ignorechars* should be a :term:`bytes-like object` or ASCII string
258-
containing characters to ignore
257+
*ignorechars* should be a byte string containing characters to ignore
259258
from the input. This should only contain whitespace characters, and by
260259
default contains all whitespace characters in ASCII.
261260

Lib/test/test_base64.py

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

968+
self.assertEqual(base64.a85decode(b"a b\nc", ignorechars=b" \n"),
969+
b'\xc9\x89')
970+
with self.assertRaises(ValueError):
971+
base64.a85decode(b"a b\nc", ignorechars=b"")
972+
with self.assertRaises(ValueError):
973+
base64.a85decode(b"a b\nc", ignorechars=b" ")
974+
with self.assertRaises(ValueError):
975+
base64.a85decode(b"a b\nc", ignorechars=b"\n")
976+
with self.assertRaises(TypeError):
977+
base64.a85decode(b"a b\nc", ignorechars=" \n")
978+
with self.assertRaises(TypeError):
979+
base64.a85decode(b"a b\nc", ignorechars=None)
980+
968981
def test_b85decode_errors(self):
969982
illegal = list(range(33)) + \
970983
list(b'"\',./:[\\]') + \

0 commit comments

Comments
 (0)