-
Notifications
You must be signed in to change notification settings - Fork 230
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
Warning subclass which break subclassing protocol break xdist #344
Comments
Hi @BrandonHoffman, Not sure what pytest-xdist can do in this case, as the Warning subclass is not following basic subclassing guarantees (keeping the same interface as the parent class). @RonnyPfannschmidt what's your opinion? |
(@BrandonHoffman took the liberty of updating the title to reflect the underlying issue better) |
xdist doesnt follow the reduce/restore protocols for serialization, so its a xdist bug for now |
I think it may be a good idea to just add a try accept around the class initialization so that it does not cause a pytest to halt abruptly with an internal error
another option for the message would be to store message_str here: nicoddemus@eb81450#diff-30240c5c51db0f0f5c8cb678115ed270R185 as
that way you can use that message in the exception case shown above This would at least fix the issue short term but I think @RonnyPfannschmidt is right it would be nice if xdist followed the reduce/restore protocols as a more long term fix. |
@BrandonHoffman that might be a valid workaround, but it seems @RonnyPfannschmidt suggestion to implement the reduce protocol is the correct one, albeit seems a lot more work because the reduce protocol (IIUC) is more complex to support. |
@nicoddemus agreed, not sure what you two think about doing a 1.23.2 release with the patch I mentioned above, would be. This way the pytest failure is resolved, while the larger reduce/restore issue is being made? |
also setstate/getstate, it basically requires a safe serialize/de-serialize just like we need it for reports as well - this is something that takes quite a while to get right |
@BrandonHoffman I'm fine with implementing a quick workaround like the one you mention and releasing
My feelings exactly. |
yeah, I can make a patch, might have to be in a few latter in the day though. |
@BrandonHoffman |
@RonnyPfannschmidt I was refreshing my memory about the reduce protocol, and as I remember, it is quite convoluted and error prone: https://docs.python.org/3/library/pickle.html#object.__reduce__ Should we:
What is your opinion? I was taking a look at fixing #349 on the weekend, and due to how warnings can be produced as |
Not sure if it's the same bug but I'm getting |
The latest xdist change causes issues whenever a subclass of the Warning class which does not set the args property due to this line: nicoddemus@eb81450#diff-cb98e0a92df3b797a1570a6e1a49b8d6R429
see the issue I created for an example: briancurtin/deprecation#36
I think it would be a good to add some error handling for cases like this in xdist so that they do not cause pytest to fail with an internal error.
The text was updated successfully, but these errors were encountered: