Ticket #13998: trac_13998_unpickle_sequence-sl.patch

File trac_13998_unpickle_sequence-sl.patch, 1.6 KB (added by slabbe, 8 years ago)
  • sage/structure/sequence.py

    # HG changeset patch
    # User Sebastien Labbe <slabqc at gmail.com>
    # Date 1358964049 -3600
    # Node ID 453c1a31eb10cd7cbf1cd3023200e2b3efdc4de9
    # Parent  a163652b02a9d49fea0ac784aaa935159e12cc00
    Fixing the hash problem for pickled Sequence
    
    diff --git a/sage/structure/sequence.py b/sage/structure/sequence.py
    a b class Sequence_generic(sage.structure.sa 
    911911            sage: S._Sequence__universe = 'foobar'
    912912            sage: S.universe()
    913913            'foobar'
     914
     915        We test that :trac:`13998` is fixed::
     916
     917            sage: S = Sequence([])
     918            sage: S.set_immutable()
     919            sage: del S._Sequence_generic__hash
     920            sage: hash(S)
     921            Traceback (most recent call last):
     922            ...
     923            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'
     924            sage: S._Sequence__hash = 34
     925            sage: hash(S)
     926            34
    914927        """
    915928        if name == "_Sequence_generic__cr" and hasattr(self,"_Sequence__cr"):
    916929            self.__cr = self._Sequence__cr
    class Sequence_generic(sage.structure.sa 
    924937        elif name == "_Sequence_generic__universe" and hasattr(self,"_Sequence__universe"):
    925938            self.__universe = self._Sequence__universe
    926939            return self.__universe
     940        elif name == "_Sequence_generic__hash" and hasattr(self,"_Sequence__hash"):
     941            self.__hash = self._Sequence__hash
     942            return self.__hash
    927943        else:
    928944            raise AttributeError("'Sequence_generic' object has no attribute '%s'"%name)
    929945seq = Sequence