diff options
author | Pete Wicken <2273100+JamoBox@users.noreply.github.com> | 2021-04-26 19:57:04 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-26 19:57:04 (GMT) |
commit | 10ad7eb2ef61a2ba99341c804c8c960e4f284621 (patch) | |
tree | 51979bebdf1d0cc36809b675ff390c9a9504e498 /Doc | |
parent | 196b8f300479d4e4050d9af9ba4ed82ee1e81dc8 (diff) | |
download | cpython-10ad7eb2ef61a2ba99341c804c8c960e4f284621.zip cpython-10ad7eb2ef61a2ba99341c804c8c960e4f284621.tar.gz cpython-10ad7eb2ef61a2ba99341c804c8c960e4f284621.tar.bz2 |
[3.8] bpo-28577: Special case added to IP v4 and v6 hosts for /32 and /128 networks (GH-18757) (#25536)
The `.hosts()` method now returns the single address present in a /32 or /128 network..
(cherry picked from commit 8e9c47a947954c997d4b725f4551d50a1d896722)
Co-authored-by: Pete Wicken <2273100+JamoBox@users.noreply.github.com>
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/ipaddress.rst | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Doc/library/ipaddress.rst b/Doc/library/ipaddress.rst index 140401d..2cdfddb 100644 --- a/Doc/library/ipaddress.rst +++ b/Doc/library/ipaddress.rst @@ -487,7 +487,8 @@ dictionaries. hosts are all the IP addresses that belong to the network, except the 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. + address are also included in the result. Networks with a mask of 32 + will return a list containing the single host address. >>> list(ip_network('192.0.2.0/29').hosts()) #doctest: +NORMALIZE_WHITESPACE [IPv4Address('192.0.2.1'), IPv4Address('192.0.2.2'), @@ -495,6 +496,8 @@ dictionaries. 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')] + >>> list(ip_network('192.0.2.1/32').hosts()) + [IPv4Address('192.0.2.1')] .. method:: overlaps(other) @@ -656,6 +659,8 @@ dictionaries. 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. + Networks with a mask of 128 will return a list containing the + single host address. .. method:: overlaps(other) .. method:: address_exclude(network) |