Open phenolophthaleinum opened 1 year ago
I also get this error when trying to deserialize instances of classes which inherit from other classes. I'm wondering if it's an issue that specifically affects inherited classes.
from pandas import CategoricalDtype
import dill
class CatDtype(CategoricalDtype):
def __init__(self, categories, ordered, other):
super().__init__(categories=categories, ordered=ordered)
self.other = other
cdt = CatDtype(categories=['A', 'B'], ordered=False, other='TEMP')
dill.dump(cdt, open('temp', 'wb'))
cdt2 = dill.load(open('temp', 'rb'))
cdt2.other
Results in:
AttributeError: 'CatDtype' object has no attribute 'other'
I actually figured out above ^ it is because the inherited class had custom __getstate__
and __setstate__
I'm trying to load a supposedly correctly dumped object of the following custom class that stores alternative names of keys from main dict as a dict where keys are aliases and values are lists of corresponding keys from main dict:
utils.py:
table_parser.py:
This produces an error:
Seems like dill does not serialize aliases, which is true if I try to serialize object with json - only dict is serialized, no trace of aliases. Why is that a case? If not serialized, everything works fine.
dill version 0.3.7 Python 3.10.6 Windows 10