]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.12] gh-117566: fix IPv6Address.is_loopback for IPv4-mapped loopbacks (GH-117567...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 29 Apr 2024 14:41:26 +0000 (16:41 +0200)
committerGitHub <noreply@github.com>
Mon, 29 Apr 2024 14:41:26 +0000 (14:41 +0000)
commit3989894a396c8c2abc78fcd8758542eed0f68912
treed48a4a9bfdd8e92c3ce998358ba16583a286db29
parent817190c303e0650d7da5e52e82feb6505fc6b761
[3.12] gh-117566: fix IPv6Address.is_loopback for IPv4-mapped loopbacks (GH-117567) (GH-118391)

gh-117566: fix IPv6Address.is_loopback for IPv4-mapped loopbacks (GH-117567)

While properties like IPv6Address.is_private account for IPv4-mapped
IPv6 addresses, such as for example:

    >>> ipaddress.ip_address("192.168.0.1").is_private
    True
    >>> ipaddress.ip_address("::ffff:192.168.0.1").is_private
    True
...the same doesn't currently apply to the is_loopback property:
    >>> ipaddress.ip_address("127.0.0.1").is_loopback
    True
    >>> ipaddress.ip_address("::ffff:127.0.0.1").is_loopback
    False

At minimum, this inconsistency between different properties is
counter-intuitive. Moreover, ::ffff:127.0.0.0/104 is for all intents and
purposes a loopback address, and should be treated as such.

(cherry picked from commit fb7f79b4da35b75cdc82ff3cf20816d2bf93d416)

Co-authored-by: Faidon Liambotis <paravoid@debian.org>
Lib/ipaddress.py
Lib/test/test_ipaddress.py
Misc/NEWS.d/next/Library/2024-04-05-15-51-01.gh-issue-117566.54nABf.rst [new file with mode: 0644]