-
-
Notifications
You must be signed in to change notification settings - Fork 178
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
Dump of decorated function in module fails #27
Comments
Replacing the last line of the file with
does and it does crash for all functions. |
@matsjoyce: thanks for the report and the test code. I think this issue is exactly the same as the one identified in issue #18. I think the solution involves passing in a "globals dict" where anything that the function doesn't require has been removed. Interestingly, if you just run your code with |
Looking at the dill logging, it runs as
When run as
When run as module,
Which means that when the file is run as
Maybe inject |
Absolutely. I think the fix, however, is to pass in a copy of I think I have bits of the code needed to do that in |
I've got some code that seems to work:
The new bit (in the middle) tries to find a module that has a |
That fix works for individual objects, but load_session fails with:
Might just be a silly mistake on my side, though. |
Ah… that's a good idea. |
The above exception can be fixed by checking if it is the main module.
Shall I make a PR? |
There are a few small things above that would need to be addressed first:
Both (1) and (2) above should be rolled up into the |
Just a suggestion:
Then, yes, do a pull request. |
The problem with that is if _import_module throws. I'll cook something up. |
Yep. So possible fix would be to catch errors in _import_module and return a None in that case. Could add a |
Something like this is python2/3 agnostic:
But handle it as you like. |
closed by #28 |
To reproduce:
Place in this code in a file:
In a interactive session or another file:
import (your file name)
I have a crash in both versions of python with the lastest source which looks like:
It looks like something to do with pickling the
__code__
attribute, then repickling it when doing the__globals__
attribute, as if you comment out the__globals__
attribute in dill.py, there is no crash (just an incomplete pickle, presumably).The text was updated successfully, but these errors were encountered: