-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-123431: Harmonize extension code checks in pickle #123434
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
gh-123431: Harmonize extension code checks in pickle #123434
Conversation
This checks are redundant in normal circumstances and can only work if the extension registry was intentionally broken. * The Python implementation now raises exception for the extension code with false boolean value. * Simplify the C code. RuntimeError is now raised in explicit checks. * Add many tests.
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. New tests cover changes, and the modified code looks correct to me.
with self.assertRaises(exc): | ||
self.dumps(MyList, proto) |
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.
with self.assertRaises(exc): | |
self.dumps(MyList, proto) | |
with self.subTest(proto=proto): | |
with self.assertRaises(exc): | |
self.dumps(MyList, proto) |
Just to know which protocol failed (I see tabs and spaces on GH so I hope that if you commit my suggestions, it will be normalized...)
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.
This is not important, because the code is the same for all protocols >= 2. Original tests for this feature only use protocol 2.
On other hand, using subTest()
will produce worse tracebacks if some test fails. Currently the traceback contains the line with the check()
call. subTest()
truncates the traceback.
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
…123434) This checks are redundant in normal circumstances and can only work if the extension registry was intentionally broken. * The Python implementation now raises exception for the extension code with false boolean value. * Simplify the C code. RuntimeError is now raised in explicit checks. * Add many tests. (cherry picked from commit 0c3ea30) Co-authored-by: Serhiy Storchaka <[email protected]>
GH-123459 is a backport of this pull request to the 3.13 branch. |
…123434) This checks are redundant in normal circumstances and can only work if the extension registry was intentionally broken. * The Python implementation now raises exception for the extension code with false boolean value. * Simplify the C code. RuntimeError is now raised in explicit checks. * Add many tests. (cherry picked from commit 0c3ea30) Co-authored-by: Serhiy Storchaka <[email protected]>
GH-123460 is a backport of this pull request to the 3.12 branch. |
… (#123459) gh-123431: Harmonize extension code checks in pickle (GH-123434) This checks are redundant in normal circumstances and can only work if the extension registry was intentionally broken. * The Python implementation now raises exception for the extension code with false boolean value. * Simplify the C code. RuntimeError is now raised in explicit checks. * Add many tests. (cherry picked from commit 0c3ea30) Co-authored-by: Serhiy Storchaka <[email protected]>
… (#123460) This checks are redundant in normal circumstances and can only work if the extension registry was intentionally broken. (cherry picked from commit 0c3ea30) Co-authored-by: Serhiy Storchaka <[email protected]>
This checks are redundant in normal circumstances and can only work if the extension registry was intentionally broken.