summaryrefslogtreecommitdiff
path: root/Lib/ipaddress.py
diff options
context:
space:
mode:
authorPeter Moody <python@hda3.com>2013-10-24 09:47:10 -0700
committerPeter Moody <python@hda3.com>2013-10-24 09:47:10 -0700
commitb1e9dfbe05cab27bd39412c001f45b86b1537877 (patch)
tree9620d2c351be22e322e8fa2080f14c9095038729 /Lib/ipaddress.py
parent2be2925d0223cf536385ca75c4d3aac57ed1cfde (diff)
downloadcpython-b1e9dfbe05cab27bd39412c001f45b86b1537877.tar.gz
#17400: correct handling of 100.64.0.0/10, fixing the docs and updating NEWS
Diffstat (limited to 'Lib/ipaddress.py')
-rw-r--r--Lib/ipaddress.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py
index 79361920b5..97ff13dfd0 100644
--- a/Lib/ipaddress.py
+++ b/Lib/ipaddress.py
@@ -1244,7 +1244,6 @@ class IPv4Address(_BaseV4, _BaseAddress):
"""
return (self in IPv4Network('0.0.0.0/8') or
self in IPv4Network('10.0.0.0/8') or
- self in IPv4Network('100.64.0.0/10') or
self in IPv4Network('127.0.0.0/8') or
self in IPv4Network('169.254.0.0/16') or
self in IPv4Network('172.16.0.0/12') or
@@ -1258,17 +1257,6 @@ class IPv4Address(_BaseV4, _BaseAddress):
self in IPv4Network('240.0.0.0/4') or
self in IPv4Network('255.255.255.255/32'))
- @property
- def is_global(self):
- """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 self in IPv4Network('100.64.0.0/10') or not self.is_private
-
@property
def is_multicast(self):
@@ -1501,6 +1489,21 @@ class IPv4Network(_BaseV4, _BaseNetwork):
if self._prefixlen == (self._max_prefixlen - 1):
self.hosts = self.__iter__
+ @property
+ @functools.lru_cache()
+ def is_global(self):
+ """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.network_address in IPv4Network('100.64.0.0/10') and
+ self.broadcast_address in IPv4Network('100.64.0.0/10')) and
+ not self.is_private)
+
+
class _BaseV6: