]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-144027: Fix documentation for ignorechars in base64.a85decode() (GH-144028...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 23 Jan 2026 19:24:06 +0000 (20:24 +0100)
committerGitHub <noreply@github.com>
Fri, 23 Jan 2026 19:24:06 +0000 (19:24 +0000)
It does not support an ASCII string.

Also add more tests.
(cherry picked from commit 25a10b60b04ab2fa802409dc6f211cf2ca028a0a)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Doc/library/base64.rst
Lib/test/test_base64.py

index 529a72424438203d5dac8da9b8b0e3b5fd9f60de..1c2c57448ceeca1bc9187ad5aa5b4fa93f7534ce 100644 (file)
@@ -239,8 +239,7 @@ Refer to the documentation of the individual functions for more information.
    *adobe* controls whether the input sequence is in Adobe Ascii85 format
    (i.e. is framed with <~ and ~>).
 
-   *ignorechars* should be a :term:`bytes-like object` or ASCII string
-   containing characters to ignore
+   *ignorechars* should be a byte string containing characters to ignore
    from the input. This should only contain whitespace characters, and by
    default contains all whitespace characters in ASCII.
 
index 60880b73f3a21db406e84f119d4e64a06b4ff333..9fe69f4f692d8f5782bdf33270d08070a0a580ad 100644 (file)
@@ -785,6 +785,19 @@ class BaseXYTestCase(unittest.TestCase):
         self.assertRaises(ValueError, base64.a85decode, b'aaaay',
                           foldspaces=True)
 
+        self.assertEqual(base64.a85decode(b"a b\nc", ignorechars=b" \n"),
+                         b'\xc9\x89')
+        with self.assertRaises(ValueError):
+            base64.a85decode(b"a b\nc", ignorechars=b"")
+        with self.assertRaises(ValueError):
+            base64.a85decode(b"a b\nc", ignorechars=b" ")
+        with self.assertRaises(ValueError):
+            base64.a85decode(b"a b\nc", ignorechars=b"\n")
+        with self.assertRaises(TypeError):
+            base64.a85decode(b"a b\nc", ignorechars=" \n")
+        with self.assertRaises(TypeError):
+            base64.a85decode(b"a b\nc", ignorechars=None)
+
     def test_b85decode_errors(self):
         illegal = list(range(33)) + \
                   list(b'"\',./:[\\]') + \