diff options
author | Pete Wicken <2273100+JamoBox@users.noreply.github.com> | 2020-03-09 22:33:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-09 22:33:45 (GMT) |
commit | 8e9c47a947954c997d4b725f4551d50a1d896722 (patch) | |
tree | 72a0d1e8aaf5962503c008323ce8ada7f037e8eb /Lib/ipaddress.py | |
parent | 9229eeee105f19705f72e553cf066751ac47c7b7 (diff) | |
download | cpython-8e9c47a947954c997d4b725f4551d50a1d896722.zip cpython-8e9c47a947954c997d4b725f4551d50a1d896722.tar.gz cpython-8e9c47a947954c997d4b725f4551d50a1d896722.tar.bz2 |
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 'Lib/ipaddress.py')
-rw-r--r-- | Lib/ipaddress.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py index 7024339..ac1143a 100644 --- a/Lib/ipaddress.py +++ b/Lib/ipaddress.py @@ -1509,6 +1509,8 @@ class IPv4Network(_BaseV4, _BaseNetwork): if self._prefixlen == (self._max_prefixlen - 1): self.hosts = self.__iter__ + elif self._prefixlen == (self._max_prefixlen): + self.hosts = lambda: [IPv4Address(addr)] @property @functools.lru_cache() @@ -2212,6 +2214,8 @@ class IPv6Network(_BaseV6, _BaseNetwork): if self._prefixlen == (self._max_prefixlen - 1): self.hosts = self.__iter__ + elif self._prefixlen == self._max_prefixlen: + self.hosts = lambda: [IPv6Address(addr)] def hosts(self): """Generate Iterator over usable hosts in a network. |