Skip to content

ipaddress: IPv6Network.exploded fails for networks with a scope ID #161384

Done

Description

@jimbou

Bug report

After gh-88178, .exploded works for a scoped IPv6Address, but a scoped IPv6Network still fails:

>>> import ipaddress
>>> n = ipaddress.IPv6Network('fe80::%eth0/64')
>>> str(n)
'fe80::%eth0/64'
>>> n.exploded
ipaddress.AddressValueError: Only hex digits permitted in '%eth0' in 'fe80::%eth0'

I'd expect 'fe80:0000:0000:0000:0000:0000:0000:0000%eth0/64'.

The network branch of _BaseV6._explode_shorthand_ip_string still re-parses str(self.network_address),
which includes the %scope. Building the hex from int(self.network_address) and appending the scope, like the
address branch, fixes it. I'm happy to send a PR with a test.

CPython versions tested on:

3.13, 3.14, CPython main branch

Operating systems tested on:

Linux

Linked PRs

Activity

  1. added
    type-bug
    on Nov 5, 2026
  2. added
    stdlib
    on Nov 5, 2026
  3. added 3 commits that reference this issue on Dec 3, 2026
  4. asvetlov commented on Dec 3, 2026

    @asvetlov
    Contributor

    Fixed

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

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions