Repository navigation
Conversation
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 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The
base64_codecincremental decoder decoded every chunk on its own, so splitting the input inside a group of four base64 characters failed:It now subclasses
codecs.BufferedIncrementalDecoderand decodes only complete groups of four alphabet characters, keeping the rest until the next call (orfinal=True). Bytes outside the alphabet (newlines,=) are not counted, sincebinascii.a2b_base64()ignores them in non-strict mode, so the joined output matches decoding the whole input at once.The
bz2_codecincremental decoder returned''(astr) when called after the end of the compressed data; it now returnsb''.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 matchesa2b_base64()(b"AA=AA="decodes, but its first four charactersb"AA=A"don't).I used Claude Code to write this change.