-
Notifications
You must be signed in to change notification settings - Fork 171
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
Prepare transition to let cloudpickle.Pickler point to CloudPickler #372
Conversation
Codecov Report
@@ Coverage Diff @@
## master #372 +/- ##
==========================================
- Coverage 92.95% 86.40% -6.56%
==========================================
Files 2 2
Lines 809 809
Branches 164 164
==========================================
- Hits 752 699 -53
- Misses 29 78 +49
- Partials 28 32 +4
Continue to review full report at Codecov.
|
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.
Could you please add a test that checks that the warning is raised and that the cloudpickle.Pickler
attribute is the same as pickle._Pickler
for the time being?
Also it seems to not work as expected at the moment:
>>> from cloudpickle import Pickler
Traceback (most recent call last):
File "<ipython-input-3-9a7c65e34d9c>", line 1, in <module>
from cloudpickle import Pickler
ImportError: cannot import name 'Pickler' from 'cloudpickle' (/home/ogrisel/code/cloudpickle/cloudpickle/__init__.py)
thank you for testing! I will add this test and avoid the f-string for older python versions. It seems that this code probably only works for python >=3.7 [1]. It works for me on 3.8, which python version are you using? There might be some 'ugly' tricks to get something like that working on <3.7 " Typical workarounds are assigning |
We could raise the |
I don't understand why the test case fails for python >= 3.7 |
The tests are failing because you added a As for the compatibility issue with In [15]: import warnings
...: import types
...: class CustomModuleType(types.ModuleType):
...: def __getattr__(self, name):
...: if name == 'Pickler':
...: warnings.warn('Pickler will point to Cloudpickler in two releases')
...: return self._Pickler
...: else:
...: raise AttributeError
...: import cloudpickle.cloudpickle as cp
...: cp.__class__ = CustomModuleType gives: In [15]: cp.Pickler
/home/pierreglaser/.virtualenvs/cloudpickle_py37/bin/ipython:6: UserWarning: Pickler will point to Cloudpickler in two releases
Out[15]: pickle._Pickler I'd rather not have |
@pierreglaser thank you! I was importing cloudpickle while being in the ./cloudpickle folder. The warnings are raised now and I can import Pickler :) but |
Ah indeed, def __reduce__(self):
return __import__, ("cloudpickle.cloudpickle",) Should be enough, although I have not checked. |
@pierreglaser it seems that the |
Probably because we forgot to define |
Warn users of a future change that
cloudpickle.Pickler
(currently pointing topickle._Pickler
) will point tocloudpickle.CloudPickler
.See #366
Replaces #235