-
-
Notifications
You must be signed in to change notification settings - Fork 181
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
Fix pickling errors thrown when saving some Stdlib modules #529
Conversation
@mmckerns: I've been working with module-saving code for months and didn't realize until now that the function >>> import dill
>>> dill.dump_module(module="dill.settings")
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-2-84d05d12f876> in <module>
----> 1 dill.dump_module(module='dill.settings')
~/Projects/forks/dill/dill/session.py in dump_module(filename, module, refimported, refonfail, **kwds)
297 main = _import_module(main)
298 if not isinstance(main, ModuleType):
--> 299 raise TypeError("%r is not a module" % main)
300 original_main = main
301 if refimported:
TypeError: {'protocol': 4, 'byref': False, 'fmode': 0, 'recurse': False, 'ignore': False, 'dump_module': {'refimported': False, 'refonfail': False}} is not a module In this case, the It seems that I'm really confused... By the way, I'm testing the " |
That's great news.
Unfortunately there are a lot of undocumented non-public functions in |
Yes, it seems that there are places where using But take a look at this listing: >>> import dill
>>> dill.__version__
'0.3.5.1'
>>> import importlib
>>> dill_settings = importlib.import_module('dill.settings')
>>> dill_settings
<module 'dill.settings' from '/home/leogama/.local/lib/python3.8/site-packages/dill/settings.py'>
>>> dill.copy(dill_settings)
{'protocol': 4, 'byref': False, 'fmode': 0, 'recurse': False, 'ignore': False}
>>> import pickletools
>>> pickletools.dis(pickletools.optimize(dill.dumps(dill_settings, protocol=0)))
0: c GLOBAL 'dill._dill _import_module'
27: ( MARK
28: V UNICODE 'dill.settings'
43: t TUPLE (MARK at 27)
44: R REDUCE
45: . STOP
highest protocol among opcodes = 0 By the way, could you help me with another issue real quick? I'd like to push a commit to Edit: here is the PR: #530 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I'll add some small pickling errors' fixes here while I test the "save unpickleable objects by reference" option.