Ticket #6184: 6184.diff

File 6184.diff, 763 bytes (added by borko, 4 years ago)
  • twisted/internet/address.py

    diff --git a/twisted/internet/address.py b/twisted/internet/address.py
    index 6b34b99..e80f460 100644
    a b class _IPAddress(FancyEqMixin, object): 
    5050        return hash((self.type, self.host, self.port))
    5151
    5252
     53    def __getitem__(self, index):
     54        if (index == 0):
     55            return self.type
     56        elif (index == 1):
     57            return self.host
     58        elif (index == 2):
     59            return self.port
     60        else:
     61            if isinstance(index, int):
     62                raise IndexError('Out of bounds key index = %s.' % index)
     63            else:
     64                raise TypeError('Invalid index type %s' % type(index))
     65
     66
    5367
    5468class IPv4Address(_IPAddress):
    5569    """