You need to define a new __setstate__ method that allows for the old and
new way of doing things. Something like:
if isinstance(state, dict): # for old pickles from Partition_class
self._set_parent(_Partitions)
self.__dict__ = state
else:
self._set_paren
Here is my solution to a similar problem in #15158:
def __setstate__(self, state):
"""
Needed to unpickle old Spec objects.
The name-mangled attribute ``__R`` used to be in a class
called ``Spec``; we have to translate this mangled name.
TESTS::
sage: S = Spec(QQ)
sage: loads(dumps(S))
Spectrum
Thanks for your answers.
* Peter Bruin [2014-05-13 01:23:56 -0700]:
> Here is my solution to a similar problem in #15158:
>
> def __setstate__(self, state):
The problem is that __setstate__ never gets called because the error
happens earlier, during the unpickling of state.
In other words, if I
Hi Julian,
OK, I see the problem. It seems that it is not unique to DirichletGroup,
but is more general:
sage: class pAdicNumber(object): pass
sage: d = { pAdicNumber(): 0 }
sage: s = dumps(d)
sage: pAdicNumber.__hash__ = None
sage: loads(s)
...
TypeError: unhashable type: 'pAdicNumber'
For al
Hello Peter,
* Peter Bruin [2014-05-13 07:05:43 -0700]:
> OK, I see the problem. It seems that it is not unique to DirichletGroup,
> but is more general:
>
> sage: class pAdicNumber(object): pass
> sage: d = { pAdicNumber(): 0 }
> sage: s = dumps(d)
> sage: pAdicNumber.__hash__ = None
> sage: