gh-145850: Change some implementation details in struct.Struct#145851
gh-145850: Change some implementation details in struct.Struct#145851serhiy-storchaka wants to merge 4 commits intopython:mainfrom
Conversation
* calling it with non-ASCII string format will now raise a ValueError instead of UnicodeEncodeError * calling it with non-ASCII bytes format will now raise a UnicodeDecodeError instead of struct.error * getting the format attribute of uninitialized object will now raise an AttributeError instead of RuntimeError.
vstinner
left a comment
There was a problem hiding this comment.
If we change exceptions, I would prefer a ValueError than an UnicodeDecodeError.
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Thank you for your review, @vstinner.
vstinner
left a comment
There was a problem hiding this comment.
LGTM.
Raising ValueError if the format is invalid makes more sense than UnicodeEncodeError or struct.error.
Replacing RuntimeError with AttributeError is more surprising, but I'm fine with AttributeError.
If a project is impacted by this change, it's possible to become compatible with old and new Python versions by catching old and new exceptions. For example, except (UnicodeEncodeError, ValueError):. But I don't expect any project to catch exceptions since they're not supposed to pass invalid format string anyway :-)
|
CIFuzz found a bug, and it seems related to the changes! To download the testcase, see https://github.com/python/cpython/actions/runs/23007198595/artifacts/5892860339. |
|
Oh, it is just incompatible with these changes, since they add a cpython/Modules/_xxtestfuzz/fuzzer.c Line 136 in d4cc553 |
Uh oh!
There was an error while loading. Please reload this page.