]> granicus.if.org Git - python/commitdiff
Issue #19157: Include the broadcast address in the usuable hosts for IPv6
authorPeter Moody <python@hda3.com>
Tue, 11 Mar 2014 16:55:46 +0000 (09:55 -0700)
committerPeter Moody <python@hda3.com>
Tue, 11 Mar 2014 16:55:46 +0000 (09:55 -0700)
in ipaddress.

Lib/ipaddress.py
Misc/NEWS

index dd71347fa9addd5d548e93e0d356a5990a5062f4..54df39ae5622019bd14504731f3c866f3d27ed24 100644 (file)
@@ -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.
index f8dda9e3010e1995bbb30233851e5b14118e0f22..d1d0401652391c21c6dcd683ec135eb698887ace 100644 (file)
--- 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.