diff options
author | Xiang Zhang <angwerzx@126.com> | 2018-03-21 00:25:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-21 00:25:13 (GMT) |
commit | 10b134a07c898c2fbc5fd3582503680a54ed80a2 (patch) | |
tree | 32ce163bf6c42d52dcbf62a6479de258c014ea04 /Doc | |
parent | 5609b78392d59c7362ef8aa5c4a4529325f01f27 (diff) | |
download | cpython-10b134a07c898c2fbc5fd3582503680a54ed80a2.zip cpython-10b134a07c898c2fbc5fd3582503680a54ed80a2.tar.gz cpython-10b134a07c898c2fbc5fd3582503680a54ed80a2.tar.bz2 |
bpo-27683: Fix a regression for host() of ipaddress network objects (GH-6016)
The result of host() was not empty when the network is constructed by a tuple containing an
integer mask and only 1 bit left for addresses.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/ipaddress.rst | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Doc/library/ipaddress.rst b/Doc/library/ipaddress.rst index 935add17..b7b502a 100644 --- a/Doc/library/ipaddress.rst +++ b/Doc/library/ipaddress.rst @@ -485,12 +485,16 @@ dictionaries. Returns an iterator over the usable hosts in the network. The usable hosts are all the IP addresses that belong to the network, except the - network address itself and the network broadcast address. + network address itself and the network broadcast address. For networks + with a mask length of 31, the network address and network broadcast + address are also included in the result. >>> list(ip_network('192.0.2.0/29').hosts()) #doctest: +NORMALIZE_WHITESPACE [IPv4Address('192.0.2.1'), IPv4Address('192.0.2.2'), IPv4Address('192.0.2.3'), IPv4Address('192.0.2.4'), IPv4Address('192.0.2.5'), IPv4Address('192.0.2.6')] + >>> list(ip_network('192.0.2.0/31').hosts()) + [IPv4Address('192.0.2.0'), IPv4Address('192.0.2.1')] .. method:: overlaps(other) @@ -647,6 +651,12 @@ dictionaries. .. attribute:: num_addresses .. attribute:: prefixlen .. method:: hosts() + + Returns an iterator over the usable hosts in the network. The usable + hosts are all the IP addresses that belong to the network, except the + Subnet-Router anycast address. For networks with a mask length of 127, + the Subnet-Router anycast address is also included in the result. + .. method:: overlaps(other) .. method:: address_exclude(network) .. method:: subnets(prefixlen_diff=1, new_prefix=None) |