summaryrefslogtreecommitdiff
path: root/Doc/library
diff options
context:
space:
mode:
authorPete Wicken <2273100+JamoBox@users.noreply.github.com>2020-03-09 22:33:45 +0000
committerGitHub <noreply@github.com>2020-03-09 15:33:45 -0700
commit8e9c47a947954c997d4b725f4551d50a1d896722 (patch)
tree72a0d1e8aaf5962503c008323ce8ada7f037e8eb /Doc/library
parent9229eeee105f19705f72e553cf066751ac47c7b7 (diff)
downloadcpython-git-8e9c47a947954c997d4b725f4551d50a1d896722.tar.gz
bpo-28577: Special case added to IP v4 and v6 hosts for /32 and /128 networks (GH-18757)
The `.hosts()` method now returns the single address present in a /32 or /128 network.
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/ipaddress.rst7
1 files changed, 6 insertions, 1 deletions
diff --git a/Doc/library/ipaddress.rst b/Doc/library/ipaddress.rst
index 5938439941..5f5e66412d 100644
--- a/Doc/library/ipaddress.rst
+++ b/Doc/library/ipaddress.rst
@@ -509,7 +509,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'),
@@ -517,6 +518,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)
@@ -678,6 +681,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)