Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Trac 18540: implement __setstate__ to fix unpickling of old instances
Browse files Browse the repository at this point in the history
  • Loading branch information
pjbruin committed May 29, 2015
1 parent 5c32c32 commit 1285b0e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/sage/modular/dirichlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1946,6 +1946,21 @@ def __init__(self, modulus, zeta, zeta_order):
self._module = free_module.FreeModule(rings.IntegerModRing(zeta_order),
len(self._integers.unit_gens()))

def __setstate__(self, state):
"""
Used for unpickling old instances.
TESTS::
sage: G = DirichletGroup(9)
sage: loads(dumps(G)) is G
True
"""
self._set_element_constructor()
if '_zeta_order' in state:
state['_zeta_order'] = rings.Integer(state['_zeta_order'])
super(DirichletGroup_class, self).__setstate__(state)

def change_ring(self, R, zeta=None, zeta_order=None):
"""
Return the base extension of ``self`` to ``R``.
Expand Down

0 comments on commit 1285b0e

Please sign in to comment.