[mypyc] Fix b64decode to match new cpython behavior#21200
Merged
p-sawicki merged 1 commit intopython:masterfrom Apr 10, 2026
Merged
[mypyc] Fix b64decode to match new cpython behavior#21200p-sawicki merged 1 commit intopython:masterfrom
p-sawicki merged 1 commit intopython:masterfrom
Conversation
JukkaL
approved these changes
Apr 10, 2026
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.
Fixes #21120
Behavior of
base64.b64decodewas recently fixed in cpython to no longer stop processing the input data after the first padded quad. This resulted in a failure in one of our tests as the result of the librt implementation was no longer the same.Update the librt implementation to match the new correct behavior. Inputs where there are valid base64 characters after padding are rejected by
libbase64so we fall back to the slow path where we preprocess the input. Currently this preprocessing matches the buggy behavior where we stop processing after the first padded quad. Change this to instead ignore padding in the middle of input, and only copy padding at the end.Behavior of librt will now be correct regardless of python version at runtime as it doesn't seem worthwhile to preserve the buggy behavior for compatibility. So modify the test to only perform checks on input where there's data after padding with the python versions that have the bugfix.