Ticket #7516: trac_7516.patch

File trac_7516.patch, 1.4 KB (added by was, 11 years ago)
  • sage/modules/free_module.py

    # HG changeset patch
    # User William Stein <wstein@gmail.com>
    # Date 1263906157 28800
    # Node ID 9cb51a984397cf36a609e7eb615e581f35cf7461
    # Parent  47169dc430e653bafdec63f2bd7a5884d27afe7b
    trac 7516 -- bug in pickling quotient module over pid
    
    diff -r 47169dc430e6 -r 9cb51a984397 sage/modules/free_module.py
    a b  
    45894589            -3713095619189944444 # 64-bit
    45904590            sage: U is V
    45914591            True
    4592         """
    4593         return hash(self.__basis)
     4592
     4593        TESTS::
     4594
     4595        We verify that trac 7516 is fixed, which involves unpickling
     4596        an object failing due to hash being called during the
     4597        unpickle::
     4598
     4599            sage: V = VectorSpace(QQ, 2)
     4600            sage: W = V.subspace([V([1,1])])
     4601            sage: Z = W.subspace([])
     4602            sage: WmodZ = W / Z
     4603            sage: WmodZ(W(0))
     4604            (0)
     4605            sage: loads(dumps(WmodZ)) == WmodZ
     4606            True
     4607        """
     4608        try:
     4609            return hash(self.__basis)
     4610        except AttributeError:
     4611            # This is a fallback because sometimes hash is called during object
     4612            # reconstruction (unpickle), and the above fields haven't been
     4613            # filled in yet.
     4614            return 0
    45944615
    45954616    def construction(self):
    45964617        """