Skip to content

gh-155836: Fix IPv6Address.reverse_pointer for addresses with a scope ID - #163096

Open
asvetlov wants to merge 2 commits into
python:mainfrom
asvetlov:gh-155836-reverse-pointer-scope
Open

asvetlov wants to merge 2 commits into
python:mainfrom
asvetlov:gh-155836-reverse-pointer-scope

Conversation

@asvetlov

@asvetlov asvetlov commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

IPv6Address('fe80::1%eth0').reverse_pointer currently includes the reversed scope ID (0.h.t.e.%.1.0...ip6.arpa). The scope ID is not part of the address, so it must not appear in the reverse DNS name.

This builds on #155837 by @tonghuaroot (their commit is kept), which has been inactive since August. Instead of stripping %scope_id from exploded, IPv6Address._reverse_pointer now builds the name from the integer value. This also handles IPv4-mapped addresses with a scope ID, so the separate IPv4-mapped code path is no longer needed.

Tests cover a named scope, a numeric scope, and an IPv4-mapped address with a scope.

Note: IPv6Interface inherits this method, so IPv6Interface('fe80::1%eth0/64').reverse_pointer now returns the address's pointer instead of one containing 4.6./. Network reverse_pointer is unchanged; it is tracked separately in gh-74713 / gh-91601.

tonghuaroot and others added 2 commits December 3, 2026 16:19
… scope id

_reverse_pointer derives from self.exploded, which since pythongh-88178 carries
the %scope_id suffix. Strip the scope id before building the pointer so it
is not spliced into the reversed nibbles.
Derive the name from the address's integer value instead of stripping the
scope ID out of the exploded string. This also drops the special case for
IPv4-mapped addresses. Add tests for a numeric scope ID and for an
IPv4-mapped address with a scope ID.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants