-
Notifications
You must be signed in to change notification settings - Fork 164
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
Incorrect pickles for subclasses of generic classes #440
Comments
Hi @huzecong, thanks for the report. Indeed, it seems like we've been a bit reckless in our handling of the base classes of "subclasses of generic classes". The reason for cloudpickle/cloudpickle/cloudpickle.py Lines 945 to 952 in fca7b22
Not sure exactly of how to arbitrate between the two possible types of base classes in such hybrid cases of subclasses of generic classes, but feel free to submit a patch if you decide to do some additional digging on that topic. For the record, here is some justification w.r.t the other conditions that need to be met in order for this bug to show up:
This comes from some automatic class memoization that cloudpickle implements. Admittedly we should expose a way to deactivate this behavior to make debugging of class-related pickling issues easier.
Pretty much only in this case will W.r.t the wrong module assignment, I'd have to dig further. |
Related issue on the latest |
Environment:
I've run into a very curious error that only manifests when a couple of conditions are satisfied:
GBase
that is a generic class (inherits fromGeneric[T]
).GBase
, notGBase[T]
orGBase[int]
).__main__
, and their code must be pickled).What I observe is then:
__module__
istypes
, instead of__main__
.Here's a script to reproduce the issue:
The output is (each row is class, set of missing base classes, and the MRO of the unpickled class):
You can see that all non-parameterized bases are missing from the MRO, and the module for all but the base classes are
types
.The text was updated successfully, but these errors were encountered: