Skip to content

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

Open

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-bugAn unexpected behavior, bug, or error
    on Nov 5, 2026
  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Nov 5, 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

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions