You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ipaddress is_private misleading for IPv4 mapped IPv6 addresses #77614
ipaddress.IPv4Address and ipaddress.IPv6Address provide a is_private function that indicates if the address (or network) is part of a "private" IP range, as designated by the IANA special-use registry.
The current documentation is as follows:
is_private
True if the address is allocated for private networks. See iana-ipv4-special-registry (for IPv4) or iana-ipv6-special-registry (for IPv6).
I consider this a bug or at least counter-intuitive, because e.g. ::ffff:8.8.8.8 is most definitely NOT a private IP address, and yet the ipaddress.is_private function reports True.
The IANA special-use registry does not contain any references to "being private" for the ::ffff region. It just designates it to be used for IPv4-mapped address.
Questionable as to if this counts as a bug or not, but I agree it is counter-intuitive given the purpose of actually checking the .is_private property of an address. So updating the behavior makes sense, but I'll be conservative w.r.t. behavior changes and not apply this to a 3.9 or earlier.
Activity
ThomasKriechbaumer commentedon May 5, 2018
ipaddress.IPv4Address and ipaddress.IPv6Address provide a is_private function that indicates if the address (or network) is part of a "private" IP range, as designated by the IANA special-use registry.
The current documentation is as follows:
However, IPv4-mapped IPv6 addresses are currently being reported as "private" by this function (see 22c3176#diff-0fc57874e463b95dbdfe6f80ae918ea1R1869).
I consider this a bug or at least counter-intuitive, because e.g. ::ffff:8.8.8.8 is most definitely NOT a private IP address, and yet the ipaddress.is_private function reports True.
The IANA special-use registry does not contain any references to "being private" for the ::ffff region. It just designates it to be used for IPv4-mapped address.
JamoBox commentedon May 16, 2021
I've opened a PR that should hopefully address this issue.
gpshead commentedon May 17, 2021
Questionable as to if this counts as a bug or not, but I agree it is counter-intuitive given the purpose of actually checking the .is_private property of an address. So updating the behavior makes sense, but I'll be conservative w.r.t. behavior changes and not apply this to a 3.9 or earlier.
miss-islington commentedon May 17, 2021
New changeset a44bb6d by Miss Islington (bot) in branch '3.10':
bpo-33433 Fix private address checking for IPv4 mapped IPv6. (GH-26172)
a44bb6d
gpshead commentedon May 17, 2021
thanks!