From ec0c214335b3ea76015a90da2110594e87eb20da Mon Sep 17 00:00:00 2001 From: tonghuaroot Date: Sun, 7 Jun 2026 23:54:15 +0800 Subject: [PATCH] gh-151049: Add 2001:1::3/128 (RFC 9665) to ipaddress IPv6 global exceptions IANA's IPv6 Special-Purpose Address Registry (2024-04) lists 2001:1::3/128 ("DNS-SD Service Registration Protocol Anycast", RFC 9665) as globally reachable, like 2001:1::1/128 and 2001:1::2/128. It was missing from _IPv6Constants._private_networks_exceptions, so is_global returned False for it. Add the exception and extend testReservedIpv6. --- Lib/ipaddress.py | 2 ++ Lib/test/test_ipaddress.py | 4 ++++ .../Library/2026-06-07-23-30-34.gh-issue-151049.mBlToO.rst | 4 ++++ 3 files changed, 10 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2026-06-07-23-30-34.gh-issue-151049.mBlToO.rst diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py index f1062a8cd052a55..42119aa7e74cd54 100644 --- a/Lib/ipaddress.py +++ b/Lib/ipaddress.py @@ -2394,6 +2394,8 @@ class _IPv6Constants: _private_networks_exceptions = [ IPv6Network('2001:1::1/128'), IPv6Network('2001:1::2/128'), + # RFC 9665: https://www.rfc-editor.org/rfc/rfc9665.html + IPv6Network('2001:1::3/128'), IPv6Network('2001:3::/32'), IPv6Network('2001:4:112::/48'), IPv6Network('2001:20::/28'), diff --git a/Lib/test/test_ipaddress.py b/Lib/test/test_ipaddress.py index 3f017b97dc28a38..26733f11d3690d2 100644 --- a/Lib/test/test_ipaddress.py +++ b/Lib/test/test_ipaddress.py @@ -2488,6 +2488,10 @@ def testReservedIpv6(self): self.assertFalse(ipaddress.ip_address('2001::').is_global) self.assertTrue(ipaddress.ip_address('2001:1::1').is_global) self.assertTrue(ipaddress.ip_address('2001:1::2').is_global) + # gh-151049: RFC 9665 anycast address (IANA 2024-04 registration) + self.assertTrue(ipaddress.ip_address('2001:1::3').is_global) + self.assertFalse(ipaddress.ip_address('2001:1::3').is_private) + self.assertFalse(ipaddress.ip_address('2001:1::4').is_global) self.assertFalse(ipaddress.ip_address('2001:2::').is_global) self.assertTrue(ipaddress.ip_address('2001:3::').is_global) self.assertFalse(ipaddress.ip_address('2001:4::').is_global) diff --git a/Misc/NEWS.d/next/Library/2026-06-07-23-30-34.gh-issue-151049.mBlToO.rst b/Misc/NEWS.d/next/Library/2026-06-07-23-30-34.gh-issue-151049.mBlToO.rst new file mode 100644 index 000000000000000..0fa338e62f56d15 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-06-07-23-30-34.gh-issue-151049.mBlToO.rst @@ -0,0 +1,4 @@ +:mod:`ipaddress`: fix ``is_global`` and ``is_private`` for the +``2001:1::3/128`` (DNS-SD Service Registration Protocol Anycast) address, +which IANA registered as globally reachable per :rfc:`9665`. It is now +correctly reported with ``is_global`` ``True`` and ``is_private`` ``False``.