python / python/cpython

`IPv6Interface.ip` loses scope ID information

Open
#129,538 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

Hi, I ran into an issue in my code (in multiplemonomials/multicast_expert) because putting an IPv6 address into an IPv6Interface, then accessing it via the ip property loses the scope ID information.

Here's a minimal example:

>> addr = ipaddress.IPv6Address("fe80::%10")
>> addr
IPv6Address('fe80::%10')
>> addr_with_prefix = ipaddress.IPv6Interface((addr, 64))
>> addr_with_prefix
IPv6Interface('fe80::%10/64')
>> addr_with_prefix.ip
IPv6Address('fe80::')

I would expect the last line to return IPv6Address('fe80::%10'), matching the value of addr. Not 100.0% sure this is a bug, but it's certainly something I would not expect since it's not in the documentation. So I'd appreciate if a note about this could be added to the docs if nothing else! Thank you!

Note that this issue is similar, but not the same thing: https://github.com/python/cpython/issues/88178

CPython versions tested on:

3.11

Operating systems tested on:

Windows

Linked PRs
  • gh-129548

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal IPv6Address and IPv6Interface example in the issue, then review linked PR gh-129548. Determine whether the agreed resolution is to preserve the scope ID in IPv6Interface.ip or document the current behavior; done means the chosen behavior or documentation matches that expectation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.