Skip to content
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

Make validation notes picklable. #408

Merged
merged 1 commit into from
Aug 5, 2023
Merged

Conversation

PIG208
Copy link
Contributor

@PIG208 PIG208 commented Aug 5, 2023

Certain test runners (in my case, Django's RemoteTestRunner) pickle the exceptions raised to accumulate them from multiple processes.

For exceptions with AttributeValidationNote and/or IterableValidationNote attached, because we have overridden __new__ on these classes, pickle cannot correctly unpickle them with the required arguments. For this use case, exceptions being pickable is necessary to accumulate errors with the multiprocessing setup.

This implements __getnewargs__ to fix this problem.

@PIG208 PIG208 changed the title Make validation notes pickable. Make validation notes picklable. Aug 5, 2023
Certain test runners pickle the exceptions raised to accumulate them from
multiple processes.

For exceptions with `AttributeValidationNote` and/or `IterableValidationNote`
attached, because we have overridden `__new__` on these classes, pickle cannot
correctly unpickle them with the required arguments. For this use case,
exceptions being picklable is necessary to accumulate errors with the
`multiprocessing` setup.

This implements `__getnewargs__` to fix this problem.

Certain test runners that pickle the exceptions raised to accumulate
them from multiple processes. For exceptions with `AttributeValidationNote`
and/or `IterableValidationNote`, because we have overriden __new__ on
these classes, pickle is not able to correctly unpickle them with the required
arguments. This implements __getnewargs__ to fix this problem.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
@Tinche
Copy link
Member

Tinche commented Aug 5, 2023

Thanks!

@Tinche Tinche merged commit 992b137 into python-attrs:main Aug 5, 2023
8 of 9 checks passed
@PIG208 PIG208 deleted the pickle branch August 5, 2023 14:56
Sign up for free to 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