This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: ipaddress is_private misleading for IPv4 mapped IPv6 addresses
Type: enhancement Stage: commit review
Components: Library (Lib) Versions: Python 3.11, Python 3.10
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Thomas Kriechbaumer, Wicken, gregory.p.smith, miss-islington
Priority: normal Keywords: patch

Created on 2018-05-05 13:34 by Thomas Kriechbaumer, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 26172 merged Wicken, 2021-05-16 17:47
PR 26189 merged miss-islington, 2021-05-17 07:52
Messages (5)
msg316213 - (view) Author: Thomas Kriechbaumer (Thomas Kriechbaumer) Date: 2018-05-05 13:34
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).

However, IPv4-mapped IPv6 addresses are currently being reported as "private" by this function (see

I consider this a bug or at least counter-intuitive, because e.g. ::ffff: 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.
msg393749 - (view) Author: Pete Wicken (Wicken) * Date: 2021-05-16 17:51
I've opened a PR that should hopefully address this issue.
msg393789 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2021-05-17 07:33
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.
msg393823 - (view) Author: miss-islington (miss-islington) Date: 2021-05-17 19:42
New changeset a44bb6ddb17538b7b2096d13eb79a1208bd97f34 by Miss Islington (bot) in branch '3.10':
bpo-33433 Fix private address checking for IPv4 mapped IPv6. (GH-26172)
msg393824 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2021-05-17 19:43
Date User Action Args
2022-04-11 14:59:00adminsetgithub: 77614
2021-05-17 19:43:01gregory.p.smithsetstatus: open -> closed
resolution: fixed
messages: + msg393824

stage: patch review -> commit review
2021-05-17 19:42:35miss-islingtonsetmessages: + msg393823
2021-05-17 07:52:44miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request24806
2021-05-17 07:33:04gregory.p.smithsetversions: + Python 3.10, Python 3.11, - Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8
nosy: + gregory.p.smith

messages: + msg393789

type: enhancement
2021-05-16 17:51:04Wickensetmessages: + msg393749
2021-05-16 17:47:26Wickensetkeywords: + patch
stage: patch review
pull_requests: + pull_request24799
2020-03-03 20:18:14Wickensetnosy: + Wicken
2018-05-05 13:34:54Thomas Kriechbaumercreate