Skip to content

Test pickling a simple callable (does not work). - #3906

Merged
rwgk merged 4 commits into
pybind:masterfrom
rwgk:pickle_callable
May 2, 2022
Merged

Test pickling a simple callable (does not work).#3906
rwgk merged 4 commits into
pybind:masterfrom
rwgk:pickle_callable

Conversation

@rwgk

@rwgkrwgk commented Apr 26, 2022

Copy link
Copy Markdown
Collaborator

Description

Currently only documents that it does not work for C Python (it only works for PyPy). Starting point for future fix.

Suggested changelog entry:

@rwgk
rwgk requested review from Skylion007 and henryiiiApril 26, 2022 19:42
serialized = pickle.dumps(m.simple_callable)
deserialized = pickle.loads(serialized)
assert deserialized() == 20220426
else:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we really want to test the broken behavior of CPython or just wrap this test with a non-strict xfail? At the very least, we should add a comment that this is a CPython bug not a PyPy bug and that PyPY is doing the preferred behavior for once.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

I added a comment to be explicit.

The test as-is gives unambiguous information about the where & what, in 3 lines.

strict xfail would lose where & what exactly the failure is.

non-strict xfail would lose almost all information about the where & what.

unless it's tracked in a comment, which is about as many characters, only not executable code, therefore leaving room for doubts and misunderstandings.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@rwgk You can add a raises arg to xfail, but I see what you mean.

@rwgk

rwgk commented May 2, 2022

Copy link
Copy Markdown
CollaboratorAuthor

Thanks Aaron! Merging this now, to get this into the smart_holder update.

@rwgk
rwgk merged commit 287e4f2 into pybind:masterMay 2, 2022
@rwgk
rwgk deleted the pickle_callable branch May 2, 2022 19:39
@github-actionsgithub-actionsBot added the needs changelog Possibly needs a changelog entry label May 2, 2022
@rwgkrwgk removed the needs changelog Possibly needs a changelog entry label May 2, 2022
@rwgkrwgk mentioned this pull request Feb 10, 2023
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@rwgk@Skylion007