@@ -310,7 +310,7 @@ def collapse_addresses(addresses):
310310 [IPv4Network('192.0.2.0/24')]
311311
312312 Args:
313- addresses: An iterator of IPv4Network or IPv6Network objects.
313+ addresses: An iterable of IPv4Network or IPv6Network objects.
314314
315315 Returns:
316316 An iterator of the collapsed IPv(4|6)Network objects.
@@ -1840,9 +1840,6 @@ def _string_from_ip_int(cls, ip_int=None):
18401840 def _explode_shorthand_ip_string (self ):
18411841 """Expand a shortened IPv6 address.
18421842
1843- Args:
1844- ip_str: A string, the IPv6 address.
1845-
18461843 Returns:
18471844 A string, the expanded IPv6 address.
18481845
@@ -1986,6 +1983,9 @@ def is_multicast(self):
19861983 See RFC 2373 2.7 for details.
19871984
19881985 """
1986+ ipv4_mapped = self .ipv4_mapped
1987+ if ipv4_mapped is not None :
1988+ return ipv4_mapped .is_multicast
19891989 return self in self ._constants ._multicast_network
19901990
19911991 @property
@@ -1997,6 +1997,9 @@ def is_reserved(self):
19971997 reserved IPv6 Network ranges.
19981998
19991999 """
2000+ ipv4_mapped = self .ipv4_mapped
2001+ if ipv4_mapped is not None :
2002+ return ipv4_mapped .is_reserved
20002003 return any (self in x for x in self ._constants ._reserved_networks )
20012004
20022005 @property
@@ -2007,6 +2010,9 @@ def is_link_local(self):
20072010 A boolean, True if the address is reserved per RFC 4291.
20082011
20092012 """
2013+ ipv4_mapped = self .ipv4_mapped
2014+ if ipv4_mapped is not None :
2015+ return ipv4_mapped .is_link_local
20102016 return self in self ._constants ._linklocal_network
20112017
20122018 @property
@@ -2063,6 +2069,9 @@ def is_global(self):
20632069 ``is_global`` has value opposite to :attr:`is_private`, except for the ``100.64.0.0/10``
20642070 IPv4 range where they are both ``False``.
20652071 """
2072+ ipv4_mapped = self .ipv4_mapped
2073+ if ipv4_mapped is not None :
2074+ return ipv4_mapped .is_global
20662075 return not self .is_private
20672076
20682077 @property
@@ -2074,6 +2083,9 @@ def is_unspecified(self):
20742083 RFC 2373 2.5.2.
20752084
20762085 """
2086+ ipv4_mapped = self .ipv4_mapped
2087+ if ipv4_mapped is not None :
2088+ return ipv4_mapped .is_unspecified
20772089 return self ._ip == 0
20782090
20792091 @property
@@ -2085,6 +2097,9 @@ def is_loopback(self):
20852097 RFC 2373 2.5.3.
20862098
20872099 """
2100+ ipv4_mapped = self .ipv4_mapped
2101+ if ipv4_mapped is not None :
2102+ return ipv4_mapped .is_loopback
20882103 return self ._ip == 1
20892104
20902105 @property
@@ -2201,7 +2216,7 @@ def is_unspecified(self):
22012216
22022217 @property
22032218 def is_loopback (self ):
2204- return self . _ip == 1 and self .network .is_loopback
2219+ return super (). is_loopback and self .network .is_loopback
22052220
22062221
22072222class IPv6Network (_BaseV6 , _BaseNetwork ):
@@ -2314,6 +2329,8 @@ class _IPv6Constants:
23142329 IPv6Network ('2001:db8::/32' ),
23152330 # IANA says N/A, let's consider it not globally reachable to be safe
23162331 IPv6Network ('2002::/16' ),
2332+ # RFC 9637: https://www.rfc-editor.org/rfc/rfc9637.html#section-6-2.2
2333+ IPv6Network ('3fff::/20' ),
23172334 IPv6Network ('fc00::/7' ),
23182335 IPv6Network ('fe80::/10' ),
23192336 ]
0 commit comments