-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
gh-93627: Align Python implementation of pickle with C implementation of pickle #103035
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
Changes from 28 commits
9939a1c
29445b9
95cbf77
31d3b05
e928112
fa2a741
dfc4ef2
3e6e4eb
92362c1
bab3dab
3a6c8c5
9c5cd38
a8a797c
1f1b2ff
ec8d1c7
889f2ab
1900578
d822705
c900f53
a366dc5
2e7fbb7
e43d962
1e79c83
90a06d3
789fe8c
30ffb7c
3a88607
dc7d33e
d365a44
1bf64c0
f275ede
3548dc3
250accc
1ea9a1b
e58f4a1
b1bd83c
f565513
4a928aa
39ab1ed
f694005
833b2fb
c803480
7f3ee96
1f02ab2
f9dd613
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -570,6 +570,22 @@ def test_multiprocessing_exceptions(self): | |
('multiprocessing.context', name)) | ||
|
||
|
||
class PickleReductionMethodsTests(unittest.TestCase): | ||
|
||
def test_pickle_invalid_reduction_method(self): | ||
class C: | ||
__reduce_ex__ = None | ||
c = C() | ||
with self.assertRaises(TypeError): | ||
pickle.dumps(c) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What implementation does it test? The tests in this module is organized in special way. There are abstract classes which test with the specified implementation specified by class attributes, and there are concrete subclasses which specialize tests for Python and C implementations. It would be better to rewrite your tests in conformance with existing style. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @serhiy-storchaka I moved the tests to be part of |
||
|
||
class C: | ||
__reduce__ = None | ||
c = C() | ||
with self.assertRaises(TypeError): | ||
pickle.dumps(c) | ||
|
||
|
||
def load_tests(loader, tests, pattern): | ||
tests.addTest(doctest.DocTestSuite()) | ||
return tests | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Update the Python pickle module implementation to match the C implementation of the pickle module. For objects setting reduction methods like ``__reduce_ex__`` or ``__reduce__`` to ``None``, pickling will result in a ``TypeError``. | ||
eendebakpt marked this conversation as resolved.
Show resolved
Hide resolved
|
eendebakpt marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.