mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Issue #20508: Improve exception message of IPv{4,6}Network.__getitem__
Patch by Gareth Rees.
This commit is contained in:
parent
24b102e6e8
commit
28dc1186a8
3 changed files with 6 additions and 2 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue