Skip to content

Commit 1947d6e

Browse files
[3.14] gh-144027: Fix documentation for ignorechars in base64.a85decode() (GH-144028) (GH-144192)
It does not support an ASCII string. Also add more tests. (cherry picked from commit 25a10b6) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent 05356b1 commit 1947d6e

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

242-
*ignorechars* should be a :term:`bytes-like object` or ASCII string
243-
containing characters to ignore
242+
*ignorechars* should be a byte string containing characters to ignore
244243
from the input. This should only contain whitespace characters, and by
245244
default contains all whitespace characters in ASCII.
246245

Lib/test/test_base64.py

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

788+
self.assertEqual(base64.a85decode(b"a b\nc", ignorechars=b" \n"),
789+
b'\xc9\x89')
790+
with self.assertRaises(ValueError):
791+
base64.a85decode(b"a b\nc", ignorechars=b"")
792+
with self.assertRaises(ValueError):
793+
base64.a85decode(b"a b\nc", ignorechars=b" ")
794+
with self.assertRaises(ValueError):
795+
base64.a85decode(b"a b\nc", ignorechars=b"\n")
796+
with self.assertRaises(TypeError):
797+
base64.a85decode(b"a b\nc", ignorechars=" \n")
798+
with self.assertRaises(TypeError):
799+
base64.a85decode(b"a b\nc", ignorechars=None)
800+
788801
def test_b85decode_errors(self):
789802
illegal = list(range(33)) + \
790803
list(b'"\',./:[\\]') + \

0 commit comments

Comments
 (0)