Comment 6 for bug 809048

Revision history for this message
Andrew Bennetts (spiv) wrote : Re: [Bug 809048] Re: bzr crashed with AttributeError in stopTest(): '_TypeEqualityDict' object has no attribute 'clear'

Martin [gz] wrote:
> Actually, it's not quite that easy as there's now a straight
> _TypeEqualityDict<->TestCase reference link. I'll see if I can get
> upstream to accept some kind of fix.

In the interim we could add some ugly code to handle both versions:

    tef_clear = getattr(type_equality_funcs, "clear", None):
    if tef_clear is None:
        tef_instance_dict = getattr(type_equality_funcs, "__dict__", None)
        if tef_instance_dict is not None:
     tef_clear = tef_instance_dict.clear
    if tef_clear is not None:
        tef_clear()

Or perhaps we should just set the entire attribute to None, if it exists, and
rely on the assumption that by the time we do this self.assertEqual isn't going
to be invoked again:

    sentinel = object()
    if getattr(self, '_type_equality_funcs', sentinel) is not sentinel:
        self._type_equality_funcs = None

-Andrew.