Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipaddress module fails on rfc4007 scoped IPv6 addresses #78969

Closed
JeremyMcMillan mannequin opened this issue Sep 24, 2018 · 10 comments
Closed

ipaddress module fails on rfc4007 scoped IPv6 addresses #78969

JeremyMcMillan mannequin opened this issue Sep 24, 2018 · 10 comments
Assignees
Labels
3.9 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@JeremyMcMillan
Copy link
Mannequin

JeremyMcMillan mannequin commented Sep 24, 2018

BPO 34788
Nosy @terryjreedy, @ncoghlan, @asvetlov, @lisroach, @miss-islington, @tirkarthi, @mic4ael, @opavlyuk, @ohwgiles
PRs
  • bpo-34788: Add support for scoped IPv6 addresses #13772
  • bpo-44012: IPv6Address.exploded with scope_id #25824
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/asvetlov'
    closed_at = <Date 2020-02-26.14:43:17.234>
    created_at = <Date 2018-09-24.14:30:02.985>
    labels = ['type-feature', 'library', '3.9']
    title = 'ipaddress module fails on rfc4007 scoped IPv6 addresses'
    updated_at = <Date 2021-05-02.22:00:23.352>
    user = 'https://bugs.python.org/JeremyMcMillan'

    bugs.python.org fields:

    activity = <Date 2021-05-02.22:00:23.352>
    actor = 'ohwgiles'
    assignee = 'asvetlov'
    closed = True
    closed_date = <Date 2020-02-26.14:43:17.234>
    closer = 'asvetlov'
    components = ['Library (Lib)']
    creation = <Date 2018-09-24.14:30:02.985>
    creator = 'Jeremy McMillan'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 34788
    keywords = ['patch']
    message_count = 10.0
    messages = ['326240', '326312', '328960', '339928', '339978', '347186', '347976', '348893', '361358', '362693']
    nosy_count = 11.0
    nosy_names = ['terry.reedy', 'ncoghlan', 'pmoody', 'asvetlov', 'lisroach', 'miss-islington', 'xtreak', 'Jeremy McMillan', 'mic4ael', 'opavlyuk', 'ohwgiles']
    pr_nums = ['13772', '25824']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue34788'
    versions = ['Python 3.9']

    @JeremyMcMillan
    Copy link
    Mannequin Author

    JeremyMcMillan mannequin commented Sep 24, 2018

    ipaddress module has no support for scoped IPv6 addresses which prevents the use of ipaddress.ip_address() and ipaddress.IPv6Address() with (always available by default on IPv6 systems) RFC conforming IPv6 link local addresses that specify interface scope.

    https://tools.ietf.org/html/rfc4007

    This is bad because interface scope is required for connect() and bind() operations on multihomed machines, and virtualized or software defined networking will make this case very common.

    eg.

    >>> ipaddress.IPv6Address('fe80::dead:dead:beef:ffff')
    IPv6Address('fe80::dead:dead:beef:ffff')
    >>> ipaddress.IPv6Address('fe80::dead:dead:beef:ffff%eth0')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ipaddress.py", line 1900, in __init__
        self._ip = self._ip_int_from_string(addr_str)
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ipaddress.py", line 1716, in _ip_int_from_string
        raise AddressValueError("%s in %r" % (exc, ip_str)) from None
    ipaddress.AddressValueError: Only hex digits permitted in 'ffff%eth0' in 'fe80::dead:dead:beef:ffff%eth0'
    >>> ipaddress.IPv6Interface('fe80::dead:dead:beef:ffff%eth0')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ipaddress.py", line 2060, in __init__
        IPv6Address.__init__(self, addr[0])
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ipaddress.py", line 1900, in __init__
        self._ip = self._ip_int_from_string(addr_str)
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ipaddress.py", line 1716, in _ip_int_from_string
        raise AddressValueError("%s in %r" % (exc, ip_str)) from None
    ipaddress.AddressValueError: Only hex digits permitted in 'ffff%eth0' in 'fe80::dead:dead:beef:ffff%eth0'

    @JeremyMcMillan JeremyMcMillan mannequin added type-bug An unexpected behavior, bug, or error docs Documentation in the Doc dir 3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir labels Sep 24, 2018
    @JeremyMcMillan
    Copy link
    Mannequin Author

    JeremyMcMillan mannequin commented Sep 25, 2018

    @lisroach
    Copy link
    Contributor

    I think this is something that would be good to have. Jeremy would you care to make a PR for this?

    @mic4ael
    Copy link
    Mannequin

    mic4ael mannequin commented Apr 11, 2019

    I would like to fix this problem if nobody is against that. I stumbled upon the very same thing recently and I think it would be a nice opportunity to contribute.

    @JeremyMcMillan
    Copy link
    Mannequin Author

    JeremyMcMillan mannequin commented Apr 11, 2019

    I think the code in SaltStack to handle scoped IPv6 addresses is mature, so please look at these examples.

    https://github.com/saltstack/salt/blob/2085cb1078f187adf82a0cf19b39d350ff1bbd50/salt/_compat.py#L125

    @opavlyuk
    Copy link
    Mannequin

    opavlyuk mannequin commented Jul 3, 2019

    Pull request needs a review.

    @terryjreedy
    Copy link
    Member

    FWIW: Marking Component: Documentation means that the issue is only about changing the doc. Hence the auto-assignment to the nebulous docs group, which no longer exists in the form it once did. Enhancement issues nearly always need a doc change but are not marked 'Documentation'. I am not sure what Jeremy's original intent was, but the actual PR is mostly code implementing and testing the newly documented addition.

    @terryjreedy terryjreedy added 3.9 only security fixes and removed docs Documentation in the Doc dir 3.7 (EOL) end of life 3.8 only security fixes labels Jul 15, 2019
    @terryjreedy terryjreedy added type-feature A feature request or enhancement and removed type-bug An unexpected behavior, bug, or error labels Jul 15, 2019
    @opavlyuk
    Copy link
    Mannequin

    opavlyuk mannequin commented Aug 2, 2019

    Please, pay attention to this issue. Pull request needs core review.

    @terryjreedy
    Copy link
    Member

    Nick, can you comment on this and review the revised PR?

    @asvetlov asvetlov self-assigned this Feb 11, 2020
    @miss-islington
    Copy link
    Contributor

    New changeset 21da76d by opavlyuk in branch 'master':
    bpo-34788: Add support for scoped IPv6 addresses (GH-13772)
    21da76d

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants