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-144001: Support ignorechars in binascii.a2b_base64() and base64.b64decode() by serhiy-storchaka · Pull Request #144024 · python/cpython

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jan 19, 2026 •
edited by github-actions Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member
  • Issue: Add the ignorechars parameter in the Base64 decoder #144001

📚 Documentation preview 📚: https://cpython-previews--144024.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

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

All reactions
@serhiy-storchaka
serhiy-storchaka requested a review from gpshead January 19, 2026 08:29
@bedevere-app bedevere-app Bot mentioned this pull request Jan 19, 2026
Add the ignorechars parameter in the Base64 decoder #144001
Closed
@serhiy-storchaka

serhiy-storchaka commented Jan 19, 2026

Copy link
Copy Markdown
Member Author

This is a draft because I am going to apply the error handling changes in a separate issue first.

We can also apply some optimizations -- cache the ignored chars and returning on fast path after ignored characters.

All reactions

Sorry, something went wrong.

Uh oh!

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

@serhiy-storchaka
serhiy-storchaka force-pushed the base64-decode-ignorechars branch from 1b0bb87 to 192d535 Compare January 19, 2026 11:19
@serhiy-storchaka
serhiy-storchaka marked this pull request as ready for review January 19, 2026 11:20
@serhiy-storchaka
serhiy-storchaka requested a review from AA-Turner as a code owner January 19, 2026 11:20
@bedevere-app bedevere-app Bot added the awaiting core review label Jan 19, 2026
@serhiy-storchaka

serhiy-storchaka commented Jan 19, 2026

Copy link
Copy Markdown
Member Author

Well, the issue with error handling was just that the error message could be more specific in some cases. It is not a bug. It can be included in this PR.

All reactions

Sorry, something went wrong.

Uh oh!

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

@serhiy-storchaka
pythongh-144001: Support ignorechars in binascii.a2b_base64() and bas…
4f3847e
…e64.b64decode()
@serhiy-storchaka
serhiy-storchaka force-pushed the base64-decode-ignorechars branch from 192d535 to 4f3847e Compare January 19, 2026 11:23
serhiy-storchaka
serhiy-storchaka commented Jan 19, 2026
View reviewed changes
Comment thread Modules/binascii.c Resolved

Uh oh!

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

@moneebullah25

moneebullah25 commented Jan 19, 2026

Copy link
Copy Markdown
Contributor

No worries, that was the point I was just free on Sunday, so I push out a PR in case you haven't started on it. BTW your PR looks good, I am no maintainer but you just have to run ./python Tools/build/generate_global_objects.py to generate the updated header files. I hope it helps.

All reactions

Sorry, something went wrong.

Uh oh!

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

@serhiy-storchaka
Regen globals.
c128590
@serhiy-storchaka serhiy-storchaka mentioned this pull request Jan 21, 2026
Incorrect documentation for ignorechars in base64.a85decode() #144027
Closed
@serhiy-storchaka
Support any bytes-like object as ignorechars.
680dae1
picnixz
picnixz reviewed Jan 24, 2026
View reviewed changes
Comment thread Lib/base64.py Resolved

Uh oh!

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

Comment thread Lib/test/test_base64.py Resolved

Uh oh!

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

serhiy-storchaka added 2 commits January 24, 2026 11:39
@serhiy-storchaka
Merge branch 'main' into base64-decode-ignorechars
a61e16a
@serhiy-storchaka
Extend tests.
4c502e0
vstinner
vstinner approved these changes Jan 26, 2026
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I'm fine with changing validate default to True if ignorechars is specified. The change produces more precise error messages. It also adds a lot of tests which is always a good thing :-)

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Jan 26, 2026
@serhiy-storchaka
serhiy-storchaka merged commit 7febbe6 into python:main Jan 26, 2026
51 checks passed

Uh oh!

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

@bedevere-app bedevere-app Bot removed the awaiting merge label Jan 26, 2026
@serhiy-storchaka
serhiy-storchaka deleted the base64-decode-ignorechars branch January 26, 2026 18:11
@bedevere-bot

This comment was marked as off-topic.

Sign in to view
@zware

This comment was marked as off-topic.

Sign in to view
@gpshead

gpshead commented Jan 26, 2026

Copy link
Copy Markdown
Member

Taking a quick look: The docs in this PR changed the default for validate and strict_mode from False to True. But versionchanged does not mention that change and there was no deprecation period. Did this behavior change? The docs need fixing at a minimum but if the behavior changed we also need a deprecation cycle. What I understand @vstinner above to be saying is to change the default only in the case of the new parameter being supplied?

All reactions

Sorry, something went wrong.

Uh oh!

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

@gpshead

gpshead commented Jan 26, 2026

Copy link
Copy Markdown
Member

that may just be a simple doc fix. the declaration lines need to not state a value for the parameters who's default behavior varies based on context:

.. function:: b64decode(s, altchars=None, validate=False)
              b64decode(s, altchars=None, validate=True, *, ignorechars)
.. function:: a2b_base64(string, /, *, strict_mode=False)
              a2b_base64(string, /, *, strict_mode=True, ignorechars)

The text below describes a dynamic behavior on both, but people will absolutely misread the function signature and not read the text if we do not indicate it in the signature.

All reactions

Sorry, something went wrong.

Uh oh!

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

@serhiy-storchaka

serhiy-storchaka commented Jan 27, 2026

Copy link
Copy Markdown
Member Author

Sorry, I do not understand. How is it different from what is in the documentation now?

All reactions

Sorry, something went wrong.

Uh oh!

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

@serhiy-storchaka

serhiy-storchaka commented Jan 27, 2026

Copy link
Copy Markdown
Member Author

Deprecation period is needed if we want to change the existing behavior into error. But ignorechars is new, there was no existing behavior which was changed.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Jan 27, 2026

Copy link
Copy Markdown
Member

Taking a quick look: The docs in this PR changed the default for validate and strict_mode from False to True. But versionchanged does not mention that change and there was no deprecation period. Did this behavior change?

The default remains validate=False (no change). The behavior only changes if you start using the new ignorechars parameter.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Jan 27, 2026

Copy link
Copy Markdown
Member
.. function:: b64decode(s, altchars=None, validate=False)
              b64decode(s, altchars=None, validate=True, *, ignorechars)

I like that. It's quick to read.

All reactions

Sorry, something went wrong.

Uh oh!

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

thunder-coding pushed a commit to thunder-coding/cpython that referenced this pull request Feb 15, 2026
@serhiy-storchaka @thunder-coding
pythongh-144001: Support ignorechars in binascii.a2b_base64() and bas…
e7f7eed
…e64.b64decode() (pythonGH-144024)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@picnixz picnixz picnixz left review comments
@vstinner vstinner vstinner approved these changes
@gpshead gpshead Awaiting requested review from gpshead
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner

Uh oh!

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

Assignees

No one assigned

Labels

None yet

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.

7 participants

@serhiy-storchaka @moneebullah25 @bedevere-bot @zware @gpshead @vstinner @picnixz
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.