Issue #20508: Improve exception message of IPv{4,6}Network.__getitem__

Patch by Gareth Rees.
This commit is contained in:
Berker Peksag 2016-06-11 22:30:05 +03:00
parent 24b102e6e8
commit 28dc1186a8
3 changed files with 6 additions and 2 deletions

View file

@ -636,12 +636,12 @@ class _BaseNetwork(_IPAddressBase):
broadcast = int(self.broadcast_address)
if n >= 0:
if network + n > broadcast:
raise IndexError
raise IndexError('address out of range')
return self._address_class(network + n)
else:
n += 1
if broadcast + n < network:
raise IndexError
raise IndexError('address out of range')
return self._address_class(broadcast + n)
def __lt__(self, other):