summaryrefslogtreecommitdiffstats
path: root/Lib/ipaddress.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-05-17 19:42:08 (GMT)
committerGitHub <noreply@github.com>2021-05-17 19:42:08 (GMT)
commita44bb6ddb17538b7b2096d13eb79a1208bd97f34 (patch)
tree06f3b92b1d3381cfb53482647203cf75f5386e48 /Lib/ipaddress.py
parent7a588621c2854bcef6ce9eeb54349b84ac078c45 (diff)
downloadcpython-a44bb6ddb17538b7b2096d13eb79a1208bd97f34.zip
cpython-a44bb6ddb17538b7b2096d13eb79a1208bd97f34.tar.gz
cpython-a44bb6ddb17538b7b2096d13eb79a1208bd97f34.tar.bz2
bpo-33433 Fix private address checking for IPv4 mapped IPv6. (GH-26172)
For IPv4 mapped IPv6 addresses, defer privacy check to the mapped IPv4 address. Solves bug where public mapped IPv4 addresses are considered private by the IPv6 check. Automerge-Triggered-By: GH:gpshead (cherry picked from commit 83f0f8d62f279f846a92fede2244beaa0149b9d8) Co-authored-by: Pete Wicken <2273100+JamoBox@users.noreply.github.com>
Diffstat (limited to 'Lib/ipaddress.py')
-rw-r--r--Lib/ipaddress.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py
index af7aedf..4a6496a 100644
--- a/Lib/ipaddress.py
+++ b/Lib/ipaddress.py
@@ -16,6 +16,7 @@ import functools
IPV4LENGTH = 32
IPV6LENGTH = 128
+
class AddressValueError(ValueError):
"""A Value Error related to the address."""
@@ -2002,9 +2003,13 @@ class IPv6Address(_BaseV6, _BaseAddress):
Returns:
A boolean, True if the address is reserved per
- iana-ipv6-special-registry.
+ iana-ipv6-special-registry, or is ipv4_mapped and is
+ reserved in the iana-ipv4-special-registry.
"""
+ ipv4_mapped = self.ipv4_mapped
+ if ipv4_mapped is not None:
+ return ipv4_mapped.is_private
return any(self in net for net in self._constants._private_networks)
@property