From 1243c7d32c9dc700509f15274545d6ac6f138fe9 Mon Sep 17 00:00:00 2001 From: Peter Moody Date: Tue, 11 Mar 2014 09:55:46 -0700 Subject: Issue #19157: Include the broadcast address in the usuable hosts for IPv6 in ipaddress. --- Lib/ipaddress.py | 12 ++++++++++++ Misc/NEWS | 3 +++ 2 files changed, 15 insertions(+) diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py index dd71347..54df39a 100644 --- a/Lib/ipaddress.py +++ b/Lib/ipaddress.py @@ -2155,6 +2155,18 @@ class IPv6Network(_BaseV6, _BaseNetwork): if self._prefixlen == (self._max_prefixlen - 1): self.hosts = self.__iter__ + def hosts(self): + """Generate Iterator over usable hosts in a network. + + This is like __iter__ except it doesn't return the + Subnet-Router anycast address. + + """ + network = int(self.network_address) + broadcast = int(self.broadcast_address) + for x in range(network + 1, broadcast + 1): + yield self._address_class(x) + @property def is_site_local(self): """Test if the address is reserved for site-local. diff --git a/Misc/NEWS b/Misc/NEWS index f8dda9e..d1d0401 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -20,6 +20,9 @@ Core and Builtins Library ------- +- Issue #19157: Include the broadcast address in the usuable hosts for IPv6 + in ipaddress. + - Issue #20875: Prevent possible gzip "'read' is not defined" NameError. Patch by Claudiu Popa. -- cgit v0.12