Ticket #13904: trac_13904_debug_only.patch

File trac_13904_debug_only.patch, 1002 bytes (added by SimonKing, 8 years ago)

For debugging only. Increase the likelyhood that a gc occurs during a weakref callback

  • sage/structure/coerce_dict.pyx

    # HG changeset patch
    # User Volker Braun <vbraun.name@gmail.com>
    # Date 1356972479 0
    # Node ID bf1d00d28ae0f89c9e0b429a2f65f6ea53234572
    # Parent  5f0dfb0f853b2b5b858862ca543041362eb5de5f
    #13904, for debugging only: Increase the likelyhood of crashes in TripleDict.__delitem__
    
    diff --git a/sage/structure/coerce_dict.pyx b/sage/structure/coerce_dict.pyx
    a b  
    112112            sage: len(T)    # indirect doctest
    113113            0
    114114        """
     115        import gc
     116        is_enabled = gc.isenabled()
     117        gc.enable()
    115118        # r is a (weak) reference (typically to a parent), and it knows the
    116119        # stored key of the unique triple r() had been part of.
    117120        # We remove that unique triple from self.D
     
    131134            self.D._refcache.__delitem__((k1,k2,k3))
    132135        except KeyError:
    133136            pass
     137        if not is_enabled:
     138            gc.disable()
    134139
    135140cdef class TripleDict:
    136141    """