-
Notifications
You must be signed in to change notification settings - Fork 16
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
[BUG] Python implementation pickles differently than native implementation #87
Comments
Good point, but I suppose it's too late. Changing now the module name of the pure py implementation will break more things than fixing them. I close the issue as wontfix, but feel free to reply. If you find a retrocompatible solution I'll be happy to implement it. |
I don't think it should be too late - this is a pretty surprising behavior and should be fixed. Other than the tests, which can be fixed, I can't find any evidence of this change breaking externally visible behavior. # still able to load a pickle that mentions core
pickle.loads(b'cfrozendict.core\nfrozendict\np0\n((dp1\nVa\np2\nI1\nstp3\nRp4\n.') |
Mh, maybe I was too cryptic in my reply. The problem is retrocompatibility. What if someone used the pure py implementation and stored the IMHO this scenario is more common than the case someone uses two versions of Python, one to pickle and one to unpickle. This is why I said "will break more things than fixing them". |
This is not true - as I showed in my last reply - files already pickled from the pure python implementation that mention The only change is that newly pickled files will say |
Mh. I'm a bit reluctant to touch Are you completely sure that touching it and running the tests against the pure py implementation, no error comes out? I reopen the issue. |
(I would add that I wanted to reopen this issue before your comment, because it came in my mind that when God will give me time to fix #68, then the regression will raise anyway) |
As mentioned by you, this could fix #88 |
OS version:
Ubuntu 22.04.3 LTS
Python3 version:
Python 3.11.6 | packaged by conda-forge | (main, Oct 3 2023, 10:40:35) [GCC 12.3.0]
vs
This results in using the python implementation when loading a pickle from a version of python that does not support the native extension in a version of python that does support it.
A possible solution to this would be to change the
__module__
of the native implementation:This is unfortunately hard to test, as doing it in
core.py
causes many tests to fail with:This is somewhat of a false-positive since the test suite runs on a python interpreter that does have the native extension but is intentionally using the python implementation, and thus
frozendict.frozendict
really isn'tfrozendict.core.frozendict
- but this is an unrealistic situation.The text was updated successfully, but these errors were encountered: