changeset: 86579:365fd677856f user: Peter Moody date: Tue Oct 22 12:36:21 2013 -0700 files: Doc/library/ipaddress.rst Lib/ipaddress.py Lib/test/test_ipaddress.py description: #17400: fix documentation, add cache to is_global and correctly handle 100.64.0.0/10 diff -r 12bf7fc1ba76 -r 365fd677856f Doc/library/ipaddress.rst --- a/Doc/library/ipaddress.rst Tue Oct 22 20:03:47 2013 +0100 +++ b/Doc/library/ipaddress.rst Tue Oct 22 12:36:21 2013 -0700 @@ -160,7 +160,7 @@ .. attribute:: is_global - ``True`` if the address is allocated for private networks. See + ``True`` if the address is allocated for public networks. See iana-ipv4-special-registry (for IPv4) or iana-ipv6-special-registry (for IPv6). diff -r 12bf7fc1ba76 -r 365fd677856f Lib/ipaddress.py --- a/Lib/ipaddress.py Tue Oct 22 20:03:47 2013 +0100 +++ b/Lib/ipaddress.py Tue Oct 22 12:36:21 2013 -0700 @@ -984,7 +984,7 @@ @property def is_global(self): - """Test if this address is allocated for private networks. + """Test if this address is allocated for public networks. Returns: A boolean, True if the address is not reserved per @@ -1233,6 +1233,7 @@ return self in reserved_network @property + @functools.lru_cache() def is_private(self): """Test if this address is allocated for private networks. @@ -1259,14 +1260,14 @@ @property def is_global(self): - """Test if this address is allocated for private networks. + """Test if this address is allocated for public networks. Returns: A boolean, True if the address is not reserved per iana-ipv4-special-registry. """ - return not self.is_private + return self in IPv4Network('100.64.0.0/10') or not self.is_private @property @@ -1856,6 +1857,7 @@ return self in sitelocal_network @property + @functools.lru_cache() def is_private(self): """Test if this address is allocated for private networks. diff -r 12bf7fc1ba76 -r 365fd677856f Lib/test/test_ipaddress.py --- a/Lib/test/test_ipaddress.py Tue Oct 22 20:03:47 2013 +0100 +++ b/Lib/test/test_ipaddress.py Tue Oct 22 12:36:21 2013 -0700 @@ -1320,6 +1320,7 @@ '127.42.0.0/16').is_loopback) self.assertEqual(False, ipaddress.ip_network('128.0.0.0').is_loopback) self.assertEqual(True, ipaddress.ip_network('100.64.0.0/10').is_private) + self.assertEqual(False, ipaddress.ip_network('100.64.0.0/10').is_global) self.assertEqual(True, ipaddress.ip_network('192.0.2.128/25').is_private) self.assertEqual(True,