GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Incorrect documentation for ignorechars in base64.a85decode() · Issue #144027 · python/cpython

Incorrect documentation for ignorechars in base64.a85decode() #144027

New issue
Copy link
New issue
Copy link
Closed
Closed
Incorrect documentation for ignorechars in base64.a85decode()#144027
Copy link
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dir

Description

@serhiy-storchaka
serhiy-storchaka
opened on Jan 19, 2026
Issue body actions

The base64.a85decode() docstring documents the ignorechars parameter as:

    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.

But the reStructuredText documentation documents it as:

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

ASCII string does not work as ignorechars.

>>> import base64
>>> base64.a85decode(b' ', ignorechars=b' ')
b''
>>> base64.a85decode(b' ', ignorechars=' ')
TypeError: 'in <string>' requires string as left operand, not int

The change was introduced in a198645 (bpo-1753718).

Also, the "bytes-like object" term is vague and has different meaning in different places. Usually it means support of the buffer protocol, but in this case the code does not work with arbitrary objects implementing the buffer protocol. So I think it is better to return the old "byte string", as in the docstring.

cc @bitdancer.

Linked PRs

  • gh-144027: Fix documentation for ignorechars in base64.a85decode() #144028
  • [3.14] gh-144027: Fix documentation for ignorechars in base64.a85decode() (GH-144028) #144192
  • [3.13] gh-144027: Fix documentation for ignorechars in base64.a85decode() (GH-144028) #144193

Activity

  1. serhiy-storchaka
    added
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    3.13only security fixesonly security fixes
    3.14bugs and security fixesbugs and security fixes
    3.15bugs and security fixesbugs and security fixes
    on Jan 19, 2026
  2. github-project-automation
    added this to docs issueson Jan 19, 2026
  3. github-project-automation
    moved this to Todo in docs issueson Jan 19, 2026
  4. serhiy-storchaka
    added a commit that references this issue on Jan 19, 2026

    pythongh-144027: Fix documentation for ignorechars in base64.a85decode()

    a398754
  5. bitdancer commented on Jan 20, 2026

    @bitdancer
    bitdancer
    on Jan 20, 2026
    Member
    More actions

    But it does work with bytearray, array, and memoryview, so I think "bytes-like object" is correct here. As I recall, this change was part of a general drive to clean up the docs that used "byte string" to use "bytes-like object" instead specifically because byte types other that b'xxx' were supported.

    What object correctly supporting the buffer protocol does it not support? Do we need an additional term for things which support the above python types but not the buffer protocol in general? Because saying "byte string" here would not be correct.

    That I didn't check before saying ascii strings were supported is my bad :(

  6. serhiy-storchaka commented on Jan 21, 2026

    @serhiy-storchaka
    serhiy-storchaka
    on Jan 21, 2026
    MemberAuthor
    More actions

    I restored "byte string" because it is in the docstring. Both terms "byte string" and "bytes-like object" were vague, but the latter is now defined in the glossary as an object that supports the Buffer Protocol and can export a C-contiguous buffer. This has no relation to the current code of a85decode() which only uses __contains__() -- which is not a part of the Buffer Protocol.

    The current implementation works also with list and set. They are too far from "byte string" and "bytes-like object", so I think we should ignore this. On other hand, it works with array and memoryview with non-byte format not as with a C-contiguous buffer. For example, 0 in array.array('I', [32]) evaluates to False, but when interpret it as a C-contiguous buffer, 0 in memoryview(array.array('I', [32])).cast('B') evaluates to True.

    There is a PR (#102753) that replaces the Python implementation with the C implementation, and a PR (#144024) that adds ignorechars to b64decode(). The C code needs to be more concrete -- either accept a C-contiguous buffer, or only bytes objects, or bytes and bytearray objects.

  7. serhiy-storchaka commented on Jan 23, 2026

    @serhiy-storchaka
    serhiy-storchaka
    on Jan 23, 2026
    MemberAuthor
    More actions

    I would be glad to use "bytes-like object" in 3.15, because we can make it supporting any object that supports the Buffer Protocol and can export a C-contiguous buffer in the C code. But for older versions it is not technically correct. We can get bug reports that the implementation does not match the documentation and will be forced to convert ignorechars to bytes or wrap it into memoryview(...).cast('B') like we did in many other functions. This is an unnecessary complication.

  8. bitdancer commented on Jan 23, 2026

    @bitdancer
    bitdancer
    on Jan 23, 2026
    Member
    More actions

    OK, that makes sense. Ideally we'd have a better term than 'byte string', but I can't think of one. ("byte string like" :)

  9. serhiy-storchaka
    added a commit that references this issue on Jan 23, 2026

    gh-144027: Fix documentation for ignorechars in base64.a85decode() (G…

    25a10b6
  10. miss-islington
    added 2 commits that reference this issue on Jan 23, 2026

    pythongh-144027: Fix documentation for ignorechars in base64.a85decod…

    172f12c

    pythongh-144027: Fix documentation for ignorechars in base64.a85decod…

    3cb685e
  11. serhiy-storchaka
    added 2 commits that reference this issue on Jan 23, 2026

    [3.13] gh-144027: Fix documentation for ignorechars in base64.a85deco…

    cbfebb1

    [3.14] gh-144027: Fix documentation for ignorechars in base64.a85deco…

    1947d6e
  12. serhiy-storchaka
    closed this as completedon Jan 23, 2026
  13. thunder-coding
    added a commit that references this issue on Feb 15, 2026

    pythongh-144027: Fix documentation for ignorechars in base64.a85decod…

    d6ceff4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dir

    Projects

    • docs issues
      Status
      Todo
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.