Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

bpo-34722: Consistent serialization of sets in bytecode#9472

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

Closed
peterebden wants to merge3 commits intopython:mainfrompeterebden:bpo-34722

Conversation

peterebden
Copy link

@peterebdenpeterebden commentedSep 21, 2018
edited by bedevere-bot
Loading

This ensures that sets / frozensets marshal in a consistent order by sorting the serialised items before writing them. That will obviously make serialisation of such types somewhat slower.

Added a test for the case in question; it needs to usecompileall as a subprocess in order to test with different hash seeds.

https://bugs.python.org/issue34722

Py_DECREF(value);
for (i =0; i < n; i++) {
value = PyList_GetItem(l, i);
value = PyMarshal_WriteObjectToString(value, Py_MARSHAL_VERSION);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This will lost the identity of objects. For example, in{(o, 1), (o, 2)} you will get different objects after marshalling/unmarshalling.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'm not sure I can get the same objects back at present?

    def test_object_identity(self):        o = 'test'        obj = {(o, 1), (o, 2)}        data = marshal.dumps(obj)        v = marshal.loads(data)        ids_before = {id(x) for x in obj}        ids_after = {id(x) for x in marshal.loads(data)}        self.assertEqual(ids_before, ids_after)AssertionError: Items in the first set but not the second:139864671036808139864645838728

Maybe I'm misunderstanding what you mean, or that's not a good test case?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Additional tests were added in#13736. Rebase your PR and make the tests be success.

ZackerySpytz reacted with thumbs up emoji
w_object(value, p);
Py_DECREF(value);
for (i = 0; i < n; i++) {
value = PyList_GetItem(l, i);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think thePyList_GetItem() andPyList_SetItem() calls added in this patch should be replaced with thePyList_GET_ITEM() andPyList_SET_ITEM() macros.

Also,PyMarshal_WriteObjectToString() should be checked for failure.

@tirantiran removed their request for reviewApril 17, 2021 21:03
@methane
Copy link
Member

Close this because#27926 was merged.

@methanemethane closed thisMay 4, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@serhiy-storchakaserhiy-storchakaserhiy-storchaka left review comments

@ZackerySpytzZackerySpytzZackerySpytz left review comments

@benjaminpbenjaminpAwaiting requested review from benjaminp

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@peterebden@methane@serhiy-storchaka@ZackerySpytz@the-knights-who-say-ni@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp