Ticket #4301: 3k-internet-defer-4301.2.patch

File 3k-internet-defer-4301.2.patch, 1.6 KB (added by drtimcouper, 7 years ago)

version 2 with a missed deprecation included

  • twisted/internet/defer.py

     
    239239
    240240        These will be executed when the 'master' callback is run.
    241241        """
    242         assert callable(callback)
    243         assert errback == None or callable(errback)
     242        assert hasattr(callback, '__call__')
     243        assert errback is None or hasattr(errback, '__call__')
    244244        cbs = ((callback, callbackArgs, callbackKeywords),
    245245               (errback or (passthru), errbackArgs, errbackKeywords))
    246246        self.callbacks.append(cbs)
     
    570570        """
    571571        return 'FirstError[#%d, %s]' % (self.index, self.subFailure)
    572572
    573 
    574     def __cmp__(self, other):
    575         """
    576         Comparison between L{FirstError} and other L{FirstError} instances
    577         is defined as the comparison of the index and sub-failure of each
    578         instance.  L{FirstError} instances don't compare equal to anything
    579         that isn't a L{FirstError} instance.
    580 
    581         @since: 8.2
    582         """
     573    def __eq__(self, other):
    583574        if isinstance(other, FirstError):
    584             return cmp(
    585                 (self.index, self.subFailure),
    586                 (other.index, other.subFailure))
    587         return -1
     575            return (self.index, self.subFailure) == (other.index, other.subFailure)
     576        else:
     577            return False
    588578
     579    def __ne__(self,other):
     580        return not self.__eq__(other)
    589581
     582    __hash__ =  object.__hash__
    590583
     584
    591585class DeferredList(Deferred):
    592586    """
    593587    I combine a group of deferreds into one callback.