-
-
Notifications
You must be signed in to change notification settings - Fork 182
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
Classes fail to pickle in Python 3 when super is referenced when dumping session #300
Comments
CC: @robertwb |
Just adding that (after seeing this post) I found that removing uses of super() in my code solved some problems I was having with dill as well. Edit: For reference, I wasn't trying to save a session, I was experiencing the same behavior (and solution) with dilling and undilling a class instance. |
Any comments from the developers on this? It seems likely to be related to #56, #75, #209. A minimal example that causes this issue is:
Loading a.dill gives the error:
It doesn't seem to matter whether you use the old or new style super, or whether dump is byref True or False. |
I'm having the same issue. Are there any news regarding it? |
I had the same issue. It sounds like the solution in dill might be difficult, but there’s an easy workaround. For a class declared in main, for example:
instead of using super() use the explicit class name:
If you change the super class you have to remember to change the calls as well, but since it only affects classes declared in main it’s not too bad. |
@robb-brown: you are correct, this issue has the same root as #56 (and the others you referenced). I'm closing this as duplicate. We are well aware of the issue, but don't have a robust solution for it yet. @charlesccychen: thanks for reporting this issue. |
@mmckerns Do we by chance have any details (perhaps in some other issue) that clarify why #56 is the rootcause of this issue? Note that this issue manifests on Python 3 only, while #56 affects Python 2 and Python 3 according to the discussion on #56. Also, this issue is reproducible with dill==0.3.0, although this issue was added to dill-0.3.0 milestone. |
We can see that disassembled pickled output refers to class A in global namespace:
This looks very similiar to disassembled output of standard pickler obtained via
This may explain the error:
Unpickling succeeds if class A is defined in current main session. |
#75 is closely related. As a workaround for #75, Dill pickles objects that invoke Line 1390 in a2e2a59
dump_session : Line 391 in a2e2a59
Note that on Python 2, for examples mentioned here, pickling-by-reference is not triggered, because expression Line 1397 in a2e2a59
|
I think we should reopen this issue as a separate issue, wdyt @mmckerns ? |
Agreed. |
@mmckerns, I've noticed this issue continues to change the milestone label; since it is currently tagged in 0.3.3 milestone, and there is only one other issue in 0.3.3 milestone, does this mean that this issue is considered a high priority for the next milestone, or the label serves some other purpose? |
Yes, it's a high-priority item. I'm aware of the cloudpickle approach. This is on my to-do short list, but just keeps getting bumped. I worked on it a bit for this latest release, but didn't get a solution incorporated. |
Good to know, thank you! |
@tvalentyn: I had to push this out another week, and past the new release. It's still on my priority list (and fingers-crossed will get resolved, as scheduled, this month). |
The problem is still not solved :( |
@ahmedelmahy If you're stuck, there's a pretty simple workaround: |
Thanks @robb-brown
|
Wtf, it's not unpickling properly over here either. Super-class never called no matter what I do. In fact init / setstate never freakin called! |
@FruitfulApproach: this issue is resolved. So, if you are experiencing issues that you feel related to this one, then please open a new issue -- you can reference this one -- but provide a minimal example that demonstrates what you are experiencing. |
This is a problematic scenario on Python 3 (tested to be failing with Python 3.5 and 3.6). The following code dumps the main session:
When this is loaded, it causes an error:
For reference, this is the disassembled pickle output:
CC: @aaltay, @tvalentyn, @markflyhigh
The text was updated successfully, but these errors were encountered: