]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-144027: Fix documentation for ignorechars in base64.a85decode() (GH-144028)
authorSerhiy Storchaka <storchaka@gmail.com>
Fri, 23 Jan 2026 18:55:48 +0000 (20:55 +0200)
committerGitHub <noreply@github.com>
Fri, 23 Jan 2026 18:55:48 +0000 (20:55 +0200)
It does not support an ASCII string.

Also add more tests.

Doc/library/base64.rst
Lib/test/test_base64.py

index 3e7884debd59485815ef76b804dcd1297d8b8184..64d66fcf6bd50a98e552e74e2f248098c505a87c 100644 (file)
@@ -254,8 +254,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 d02992903f15a750566912abd1de44ce161b8b69..6e69ece8065ea20a18d4d7b0e26fbf406d198d69 100644 (file)
@@ -965,6 +965,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'"\',./:[\\]') + \