-
-
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
search sys.path when checking if module is builtin / binary #283
base: master
Are you sure you want to change the base?
Conversation
This will mark all modules as builtin as for them to be found means that they are accessible via |
good point, let me think more on it. Also will find another binary package and see if I can get the same issue as numpy shows since that may give more of a clue how fix it correctly. |
Most packages don't have the problems numpy has, as it does all kinds of weird magic in creating its types (most of the, don't seem to pickle properly). dill has a number of special functions to deal with them, but it seems a few more are needed... |
@atleypnorth: Thanks for taking initiative on this. I agree with @matsjoyce. I think this PR has potential, however some of the changes should come in other forms. For example, issues with |
happy to help ! Will get a bit more time next week to dig into and hopefully can come up with something |
Just going back to the first comment that the change would mark all modules as builtin - isn't this already the case for anything that for example comes out of the virtual environment? For example if am running using the python in my virtual env |
Hmm, I guess it would. Maybe we need to replace it with a completely new test. @mmckerns We could try instead to serialize the module dict, and if an exception is thrown fallback to serialization by reference? That should solve @atleypnorth's problem too? |
@matsjoyce: I don't think I have an issue with trying to serialize the module dict, and in failing... serializing by any of the other means (i.e. serialization variants) in |
@atleypnorth : is there a plan to merge this PR . we are kind of stuck due to this issue. |
Hi
Not sure of the process to submit PR, so hope this is enough info etc. If not then please let me know!
I came across an issue when we make use of PYTHONPATH to pick up modules and these modules contain shared libraries
Example code
Output
/usr/local/python/3.6.2/bin/python3 d1.py
<class 'numpy.uint64'>
/u1/morrpat/workspace/libs/1.14.3-cp36/numpy/core/multiarray.cpython-36m-x86_64-linux-gnu.so
Traceback (most recent call last):
File "d1.py", line 16, in
f()
File "d1.py", line 14, in f
dill.dump(ui, f)
File "/u1/morrpat/workspace/libs/0.2.7.1/dill/dill.py", line 274, in dump
pik.dump(obj)
File "/usr/local/python/3.6.2/lib/python3.6/pickle.py", line 409, in dump
self.save(obj)
File "/usr/local/python/3.6.2/lib/python3.6/pickle.py", line 521, in save
self.save_reduce(obj=obj, *rv)
File "/usr/local/python/3.6.2/lib/python3.6/pickle.py", line 609, in save_reduce
save(func)
File "/usr/local/python/3.6.2/lib/python3.6/pickle.py", line 476, in save
f(self, obj) # Call unbound method with explicit self
File "/u1/morrpat/workspace/libs/0.2.7.1/dill/dill.py", line 1033, in save_builtin_method
pickler.save_reduce(_get_attr, (module, obj.name), obj=obj)
File "/usr/local/python/3.6.2/lib/python3.6/pickle.py", line 610, in save_reduce
save(args)
File "/usr/local/python/3.6.2/lib/python3.6/pickle.py", line 476, in save
f(self, obj) # Call unbound method with explicit self
File "/usr/local/python/3.6.2/lib/python3.6/pickle.py", line 736, in save_tuple
save(element)
File "/usr/local/python/3.6.2/lib/python3.6/pickle.py", line 476, in save
f(self, obj) # Call unbound method with explicit self
File "/u1/morrpat/workspace/libs/0.2.7.1/dill/dill.py", line 1239, in save_module
state=_main_dict)
File "/usr/local/python/3.6.2/lib/python3.6/pickle.py", line 634, in save_reduce
save(state)
File "/usr/local/python/3.6.2/lib/python3.6/pickle.py", line 476, in save
f(self, obj) # Call unbound method with explicit self
File "/u1/morrpat/workspace/libs/0.2.7.1/dill/dill.py", line 871, in save_module_dict
StockPickler.save_dict(pickler, obj)
File "/usr/local/python/3.6.2/lib/python3.6/pickle.py", line 821, in save_dict
self._batch_setitems(obj.items())
File "/usr/local/python/3.6.2/lib/python3.6/pickle.py", line 847, in _batch_setitems
save(v)
File "/usr/local/python/3.6.2/lib/python3.6/pickle.py", line 496, in save
rv = reduce(self.proto)
TypeError: can't pickle PyCapsule objects
The fix has it check against all the paths in sys.path as well if it hasnt already determined it is a builtin module.