Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
… copy implementation
Uh oh!
There was an error while loading.Please reload this page.
@serhiy-storchaka Will you be able to review the PR? |
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
Uh oh!
There was an error while loading.Please reload this page.
Misc/NEWS.d/next/Core and Builtins/2023-03-26-19-11-10.gh-issue-93627.0UgwBL.rst OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
…e-93627.0UgwBL.rstCo-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Lib/test/test_pickle.py Outdated
def test_pickle_invalid_reduction_method(self): | ||
c = C_None_reduce_ex() | ||
with self.assertRaises(TypeError): | ||
pickle.dumps(c) |
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.
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.
eendebakptAug 28, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
@serhiy-storchaka I moved the tests to be part ofAbstractPickleTests
,AbstractPicklerUnpicklerObjectTests
andAbstractDispatchTableTests
. These are included in concrete tests both inside and outside thehas_c_implementation
section oftest_pickle.py
.
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.
Thank you for your contribution@eendebakpt. Do you mind to align also the copy module with the pickle module? It is more complex and dangerous change, because we may need to change the order of some operations which is different in copy and pickle modules. |
@serhiy-storchaka If aligning the copy of pickle module is still blocking#91610 I will have a look at the alignment. However, Jelle Zijlstra remarked in#103035 (comment) that the alignment might break some existing code, so we reverted these changes for this PR.@JelleZijlstra was your remark only about the |
@serhiy-storchaka@JelleZijlstra I created#109498 to get a feeling for the impact of aligning the behaviour of the copy module with the pickle module. Maybe more needs to be aligned, but the PR seems quite straightforward so far. |
Uh oh!
There was an error while loading.Please reload this page.
In this PR we align the python and C implementation of
pickle
module. In this PR we have chosen to modify all implementations to follow the c implementation of pickle conventions: if a method like__reduce_ex_
or__reduce__
is set toNone
, aTypeError
is raised.Since the behaviour of the python and c implemenations is not equal, any PR aliging the two cannot be fully backwards compatible. The impact seems limited:
__reduce_ex__
attribute of a class toNone
, instead of creating a method)Notes:
copy
module have been removed from the PR.