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.
vstinner
left a comment
There was a problem hiding this comment.
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.
| 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.
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 <storchaka@gmail.com>
|
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 <storchaka@gmail.com>
|
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 <storchaka@gmail.com>
This checks are redundant in normal circumstances and can only work if the extension registry was intentionally broken.