@@ -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.
@@ -1855,9 +1855,6 @@ def _string_from_ip_int(cls, ip_int=None):
18551855 def _explode_shorthand_ip_string (self ):
18561856 """Expand a shortened IPv6 address.
18571857
1858- Args:
1859- ip_str: A string, the IPv6 address.
1860-
18611858 Returns:
18621859 A string, the expanded IPv6 address.
18631860
@@ -2004,6 +2001,9 @@ def is_multicast(self):
20042001 See RFC 2373 2.7 for details.
20052002
20062003 """
2004+ ipv4_mapped = self .ipv4_mapped
2005+ if ipv4_mapped is not None :
2006+ return ipv4_mapped .is_multicast
20072007 return self in self ._constants ._multicast_network
20082008
20092009 @property
@@ -2015,6 +2015,9 @@ def is_reserved(self):
20152015 reserved IPv6 Network ranges.
20162016
20172017 """
2018+ ipv4_mapped = self .ipv4_mapped
2019+ if ipv4_mapped is not None :
2020+ return ipv4_mapped .is_reserved
20182021 return any (self in x for x in self ._constants ._reserved_networks )
20192022
20202023 @property
@@ -2025,6 +2028,9 @@ def is_link_local(self):
20252028 A boolean, True if the address is reserved per RFC 4291.
20262029
20272030 """
2031+ ipv4_mapped = self .ipv4_mapped
2032+ if ipv4_mapped is not None :
2033+ return ipv4_mapped .is_link_local
20282034 return self in self ._constants ._linklocal_network
20292035
20302036 @property
@@ -2081,6 +2087,9 @@ def is_global(self):
20812087 ``is_global`` has value opposite to :attr:`is_private`, except for the ``100.64.0.0/10``
20822088 IPv4 range where they are both ``False``.
20832089 """
2090+ ipv4_mapped = self .ipv4_mapped
2091+ if ipv4_mapped is not None :
2092+ return ipv4_mapped .is_global
20842093 return not self .is_private
20852094
20862095 @property
@@ -2092,6 +2101,9 @@ def is_unspecified(self):
20922101 RFC 2373 2.5.2.
20932102
20942103 """
2104+ ipv4_mapped = self .ipv4_mapped
2105+ if ipv4_mapped is not None :
2106+ return ipv4_mapped .is_unspecified
20952107 return self ._ip == 0
20962108
20972109 @property
@@ -2103,6 +2115,9 @@ def is_loopback(self):
21032115 RFC 2373 2.5.3.
21042116
21052117 """
2118+ ipv4_mapped = self .ipv4_mapped
2119+ if ipv4_mapped is not None :
2120+ return ipv4_mapped .is_loopback
21062121 return self ._ip == 1
21072122
21082123 @property
@@ -2219,7 +2234,7 @@ def is_unspecified(self):
22192234
22202235 @property
22212236 def is_loopback (self ):
2222- return self . _ip == 1 and self .network .is_loopback
2237+ return super (). is_loopback and self .network .is_loopback
22232238
22242239
22252240class IPv6Network (_BaseV6 , _BaseNetwork ):
@@ -2332,6 +2347,8 @@ class _IPv6Constants:
23322347 IPv6Network ('2001:db8::/32' ),
23332348 # IANA says N/A, let's consider it not globally reachable to be safe
23342349 IPv6Network ('2002::/16' ),
2350+ # RFC 9637: https://www.rfc-editor.org/rfc/rfc9637.html#section-6-2.2
2351+ IPv6Network ('3fff::/20' ),
23352352 IPv6Network ('fc00::/7' ),
23362353 IPv6Network ('fe80::/10' ),
23372354 ]
0 commit comments