Skip to content

gh-88178: IPv6Address.exploded with scope_id - #25824

Merged
serhiy-storchaka merged 4 commits into
python:mainfrom
ohwgiles:ipv6address-exploded-with-scope_id
Aug 13, 2026
Merged

gh-88178: IPv6Address.exploded with scope_id#25824
serhiy-storchaka merged 4 commits into
python:mainfrom
ohwgiles:ipv6address-exploded-with-scope_id

Conversation

@ohwgiles

@ohwgiles ohwgiles commented May 2, 2021

Copy link
Copy Markdown
Contributor

Support for scoped IPv6 addresses was implemented in bpo-34788 but missed implementing the .exploded method:

>>> import ipaddress
>>> ipaddress.IPv6Address('fe80::1%eth0').exploded
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.9/ipaddress.py", line 394, in exploded
    return self._explode_shorthand_ip_string()
  File "/usr/lib/python3.9/ipaddress.py", line 1824, in _explode_shorthand_ip_string
    ip_int = self._ip_int_from_string(ip_str)
  File "/usr/lib/python3.9/ipaddress.py", line 1705, in _ip_int_from_string
    raise AddressValueError("%s in %r" % (exc, ip_str)) from None
ipaddress.AddressValueError: Only hex digits permitted in '1%eth0' in 'fe80::1%eth0'

After this commit:

>>> import ipaddress
>>> ipaddress.IPv6Address('fe80::1%eth0').exploded
'fe80:0000:0000:0000:0000:0000:0000:0001%eth0'

https://bugs.python.org/issue44012

@github-actions

github-actions Bot commented Jun 3, 2021

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Jun 3, 2021
Support for scoped IPv6 addresses was implemented in bpo-34788
but missed implementing the .exploded method:

>>> import ipaddress
>>> ipaddress.IPv6Address('fe80::1%eth0').exploded
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.9/ipaddress.py", line 394, in exploded
    return self._explode_shorthand_ip_string()
  File "/usr/lib/python3.9/ipaddress.py", line 1824, in _explode_shorthand_ip_string
    ip_int = self._ip_int_from_string(ip_str)
  File "/usr/lib/python3.9/ipaddress.py", line 1705, in _ip_int_from_string
    raise AddressValueError("%s in %r" % (exc, ip_str)) from None
ipaddress.AddressValueError: Only hex digits permitted in '1%eth0' in 'fe80::1%eth0'

After this commit:

>>> import ipaddress
>>> ipaddress.IPv6Address('fe80::1%eth0').exploded
'fe80:0000:0000:0000:0000:0000:0000:0001%eth0'

@MaxwellDupre MaxwellDupre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good to go.

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Aug 7, 2022
@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 9, 2026
@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Aug 11, 2026
@serhiy-storchaka serhiy-storchaka changed the title bpo-44012: IPv6Address.exploded with scope_id gh-88178: IPv6Address.exploded with scope_id Aug 12, 2026
IPv6Interface.exploded silently omitted the scope ID, unlike str() and
compressed.  Attach it in one place, before the prefix length, so that
all three representations agree.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Aug 12, 2026

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed support of interfaces. LGTM now.

IPv6Interface.exploded is not documented separately, so reference the
classes instead of the attribute.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@serhiy-storchaka
serhiy-storchaka enabled auto-merge (squash) August 13, 2026 05:57
@serhiy-storchaka
serhiy-storchaka merged commit a2104b7 into python:main Aug 13, 2026
51 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @ohwgiles for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@bedevere-app

bedevere-app Bot commented Aug 13, 2026

Copy link
Copy Markdown

GH-155655 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Aug 13, 2026
@bedevere-app

bedevere-app Bot commented Aug 13, 2026

Copy link
Copy Markdown

GH-155656 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Aug 13, 2026
@bedevere-app

bedevere-app Bot commented Aug 13, 2026

Copy link
Copy Markdown

GH-155657 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Aug 13, 2026
serhiy-storchaka added a commit that referenced this pull request Aug 13, 2026
… (GH-155657)

IPv6Address.exploded raised AddressValueError, and
IPv6Interface.exploded omitted the scope ID.
(cherry picked from commit a2104b7)

Co-authored-by: Oliver Giles <[email protected]>
Co-authored-by: Serhiy Storchaka <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
serhiy-storchaka added a commit that referenced this pull request Aug 13, 2026
… (GH-155656)

IPv6Address.exploded raised AddressValueError, and
IPv6Interface.exploded omitted the scope ID.
(cherry picked from commit a2104b7)

Co-authored-by: Oliver Giles <[email protected]>
Co-authored-by: Serhiy Storchaka <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants