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 — gh-71986: Fix the base64 and bz2 codec incremental decoders by b84330808 · Pull Request #160981 · python/cpython

Conversation

@b84330808

@b84330808 b84330808 commented Oct 30, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

The base64_codec incremental decoder decoded every chunk on its own, so splitting the input inside a group of four base64 characters failed:

>>> b"".join(codecs.iterdecode([b"AA", b"AA\r\n"], "base64"))
binascii.Error: Incorrect padding

It now subclasses codecs.BufferedIncrementalDecoder and decodes only complete groups of four alphabet characters, keeping the rest until the next call (or final=True). Bytes outside the alphabet (newlines, =) are not counted, since binascii.a2b_base64() ignores them in non-strict mode, so the joined output matches decoding the whole input at once.

The bz2_codec incremental decoder returned '' (a str) when called after the end of the compressed data; it now returns b''.

Martin Panter attached a patch to the original bpo issue in 2016. This is a new implementation against current main: that patch counted = as a data character, which no longer matches a2b_base64() (b"AA=AA=" decodes, but its first four characters b"AA=A" don't).

I used Claude Code to write this change.

  • Issue: Fix base64-codec and bz2-codec incremental decoders #71986

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@b84330808 @claude
pythongh-71986: Fix the base64 and bz2 codec incremental decoders
d8f7bca
The base64_codec incremental decoder decoded each chunk on its own, so
input split in the middle of a group of four characters failed with
binascii.Error. Keep the incomplete group until the next call.

The bz2_codec incremental decoder returned a str when called after the
end of the compressed data. Return b'' instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@python-cla-bot

python-cla-bot Bot commented Oct 30, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added the awaiting review label Oct 30, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Oct 30, 2026
Fix base64-codec and bz2-codec incremental decoders #71986
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@b84330808
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.