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 — base64.b64decode error raised on valid input · Issue #145968 · python/cpython

base64.b64decode error raised on valid input #145968

New issue
Copy link
New issue
Copy link
Closed
Closed
base64.b64decode error raised on valid input#145968
Copy link
Assignees
serhiy-storchaka
Labels
3.15bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@mayeut
mayeut
opened on Mar 15, 2026
Issue body actions

Bug report

Bug description:

An error is raised for the following valid test cases using the newly introduced ignorechars parameter

import base64

assert base64.b64decode(b'/----', altchars=b'-+', ignorechars=b'/') == b'\xfb\xef\xbe'
assert base64.b64decode(b'+----', altchars=b'/-', ignorechars=b'+') == b'\xff\xff\xff'

For both we get:

binascii.Error: Invalid base64-encoded string: number of data characters (5) cannot be 1 more than a multiple of 4

In both cases, the leading byte should be ignored thus giving a 4 bytes valid input.

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

  • gh-145968: fix base64.b64decode altchars translation in specific cases #145969

Activity

  1. mayeut
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Mar 15, 2026
  2. terryjreedy commented on Mar 15, 2026

    @terryjreedy
    terryjreedy
    on Mar 15, 2026
    Member
    More actions

    @serhiy-storchaka I believe you introduced base64 ignorechars.

  3. mayeut
    changed the title [-]base64.decode error raised on valid input[/-] [+]base64.b64decode error raised on valid input[/+] on Mar 15, 2026
  4. serhiy-storchaka
    self-assigned this
    on Mar 15, 2026
  5. mayeut commented on Mar 15, 2026

    @mayeut
    mayeut
    on Mar 15, 2026
    ContributorAuthor
    More actions

    I do have a PR almost ready, I'll cc @serhiy-storchaka

  6. mayeut
    added a commit that references this issue on Mar 15, 2026

    pythongh-145968: fix base64.b64decode altchars translation in specifi…

    d484023
  7. StanFromIreland
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Mar 15, 2026
  8. picnixz
    added
    3.15bugs and security fixesbugs and security fixes
    on Mar 15, 2026
  9. serhiy-storchaka
    added a commit that references this issue on Mar 15, 2026

    gh-145968: Fix base64.b64decode altchars translation in specific cases (

    ec5e3a5
  10. serhiy-storchaka commented on Mar 15, 2026

    @serhiy-storchaka
    serhiy-storchaka
    on Mar 15, 2026
    Member
    More actions

    Thank you for your report and PR, @mayeut.

  11. serhiy-storchaka
    closed this as completedon Mar 16, 2026
  12. ljfp
    added a commit that references this issue on Apr 25, 2026

    pythongh-145968: Fix base64.b64decode altchars translation in specifi…

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

Metadata

Metadata

Assignees

  • @serhiy-storchaka
    serhiy-storchaka

Labels

3.15bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Projects

No projects

    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.