Skip to content

ipaddress: IPv6Address.reverse_pointer produces an invalid name for an address with a scope id #155836

Open

Description

@tonghuaroot

Bug report

Since gh-88178 (a2104b7), :attr:~ipaddress.IPv6Address.exploded includes
the %scope_id suffix. IPv6Address._reverse_pointer derives the pointer
from self.exploded and only strips :, so the scope id is reversed into
the name:

>>> import ipaddress
>>> ipaddress.IPv6Address('fe80::1%eth0').reverse_pointer
'0.h.t.e.%.1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.e.f.ip6.arpa'

A scope id is link-local and is not part of the address, so it must not appear
in the reverse DNS name. The correct value is the one for fe80::1:

>>> ipaddress.IPv6Address('fe80::1').reverse_pointer
'1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.e.f.ip6.arpa'

Before a2104b7 this raised :exc:~ipaddress.AddressValueError; it now returns
a malformed name silently.

Linked PRs

Activity

  1. added
    type-bug
    stdlib
    on Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibtype-bug

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions