-
-
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
dynamically generated class methods fail to pickle #58
Comments
In the test above if I change line 9 to But when I try that approach with the real program, dill still fails on circular references (but with a cell involved)
I will try to find a minimal test case to reproduce this too. |
Interesting. Maybe this is one of the things they simplified in python3, for reasons like this. |
I think in essence, this is a problem with pickle, not dill, as when saving an object, pickle resolved the dependencies before marking the object as memorised, which means that circular references are not well handled. |
This may mean digging into exactly how the object is created by python, and seeing if there's a way to rebuild it from any component parts that are pickleable. In this case, looking at what exactly |
I've found the difference with the first issue: >>> import types
>>> def f(): pass
...
>>> class A:
... def f():pass
...
>>> class A2: pass
...
>>> f2=types.MethodType(f, None, A2)
>>> A2.f=f2
>>> A.__dict__["f"]
<function f at 0x7f3d83ec7b90>
>>> A.f
<unbound method A.f>
>>> A2.__dict__["f"]
<unbound method A2.f>
>>> A2.f
<unbound method A2.f>
>>> |
Ach.. that's bordering on being a A loose plan to serialize
|
Turns out this has indeed been fixed in python3. The |
When using full class pickling (e.g.
cls.__module__ = '__main__'
), picklingdynamically generated class methods fails with
maximum recursion depth exceeded
Looks like a separate issue from #56. Maybe due to handling of the circular references?
Class.__dict__ --> method ; method.im_class --> Class
test case:
dill.detect.trace:
The text was updated successfully, but these errors were encountered: