-
Notifications
You must be signed in to change notification settings - Fork 18
Description
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]
In [4]: pickle.dumps(frozendict.frozendict(a=1), protocol=0)
Out[4]: b'cfrozendict.core\nfrozendict\np0\n((dp1\nVa\np2\nI1\nstp3\nRp4\n.'vs
In [10]: pickle.dumps(frozendict.frozendict(a=1), protocol=0)
Out[10]: b'cfrozendict\nfrozendict\np0\n((dp1\nVa\np2\nI1\nstp3\nRp4\n.'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:
frozendict.__module__ = 'frozendict'This is unfortunately hard to test, as doing it in core.py causes many tests to fail with:
_pickle.PicklingError: Can't pickle <class 'frozendict.frozendict'>: it's not the same object as frozendict.frozendict
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't frozendict.core.frozendict - but this is an unrealistic situation.