Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-144001: Support ignorechars in binascii.a2b_base64() and base64.b64decode()#144024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@serhiy-storchaka
Copy link
Member

@serhiy-storchakaserhiy-storchaka commentedJan 19, 2026
edited by github-actionsbot
Loading

@serhiy-storchaka
Copy link
MemberAuthor

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.

@serhiy-storchaka
Copy link
MemberAuthor

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.

@moneebullah25
Copy link
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.

Copy link
Member

@vstinnervstinner left a 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 ifignorechars is specified. The change produces more precise error messages. It also adds a lot of tests which is always a good thing :-)

@serhiy-storchakaserhiy-storchaka merged commit7febbe6 intopython:mainJan 26, 2026
51 checks passed
@serhiy-storchakaserhiy-storchaka deleted the base64-decode-ignorechars branchJanuary 26, 2026 18:11
@bedevere-bot

This comment was marked as off-topic.

@zware

This comment was marked as off-topic.

@gpshead
Copy link
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 defaultonly in the case of the new parameter being supplied?

@gpshead
Copy link
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.

@serhiy-storchaka
Copy link
MemberAuthor

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

@serhiy-storchaka
Copy link
MemberAuthor

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

@vstinner
Copy link
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 remainsvalidate=False (no change). The behavior only changes if you start using the newignorechars parameter.

@vstinner
Copy link
Member

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

I like that. It's quick to read.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@picnixzpicnixzpicnixz left review comments

@vstinnervstinnervstinner approved these changes

@gpsheadgpsheadAwaiting requested review from gpshead

@AA-TurnerAA-TurnerAwaiting requested review from AA-TurnerAA-Turner is a code owner

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

7 participants

@serhiy-storchaka@moneebullah25@bedevere-bot@zware@gpshead@vstinner@picnixz

[8]ページ先頭

©2009-2026 Movatter.jp