Skip to content

gh-62040: Raise ValueError on invalid *errors* argument in several codecs #136611

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

StanFromIreland
Copy link
Member

@StanFromIreland StanFromIreland commented Jul 13, 2025

@StanFromIreland StanFromIreland changed the title gh-62040: Raise ValueError on invalid *errors* parameter in several codecs gh-62040: Raise ValueError on invalid *errors* argument in several codecs Jul 13, 2025
@efimov-mikhail
Copy link
Contributor

I can see that there's only some changes from last patch:
https://bugs.python.org/file30902/issue17840.patch

For example, I'd like to remove also assert self.errors == 'strict', use _check_strict method in all files, test new changes.

@StanFromIreland
Copy link
Member Author

Ah I forgot about the patch and my grep was too strict, I'll fix all the self.errors cases.

@StanFromIreland StanFromIreland marked this pull request as draft July 14, 2025 13:16
@StanFromIreland StanFromIreland marked this pull request as ready for review July 24, 2025 08:22
@@ -8,14 +8,20 @@
import codecs
import base64

### Codec Helpers

def _assert_strict(errors):
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe _check_strict from the original patch would be better?

Copy link
Member Author

Choose a reason for hiding this comment

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

I prefer assert_strict since it is closer to what was there before, and it is more obvious, to me at least, that it will fail if errors != 'strict', whereas check_strict, seems like something that will enable more verbose errors or the like.

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO, it's not fully correct to name method assert_something and don't make any assert checks or raising an AssertionError.

Copy link
Member Author

Choose a reason for hiding this comment

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

@malemburg which do you prefer? _check_strict or _assert_strict

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy