Skip to content

[mypyc] Fix b64decode to match new cpython behavior#21200

Merged
p-sawicki merged 1 commit intopython:masterfrom
p-sawicki:librt-base64-python3.14.4-compat
Apr 10, 2026
Merged

[mypyc] Fix b64decode to match new cpython behavior#21200
p-sawicki merged 1 commit intopython:masterfrom
p-sawicki:librt-base64-python3.14.4-compat

Conversation

@p-sawicki
Copy link
Copy Markdown
Collaborator

@p-sawicki p-sawicki commented Apr 10, 2026

Fixes #21120

Behavior of base64.b64decode was 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 libbase64 so 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.

@p-sawicki p-sawicki merged commit c6d938e into python:master Apr 10, 2026
17 checks passed
@p-sawicki p-sawicki deleted the librt-base64-python3.14.4-compat branch April 10, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

testAllBase64Features_librt fails with Python 3.14.4

2 participants