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: Wrong behavior with ::ffff:1.2.3.4 style IPs #71456

Open
ThiefMaster mannequin opened this issue Jun 8, 2016 · 4 comments
Open

ipaddress: Wrong behavior with ::ffff:1.2.3.4 style IPs #71456

ThiefMaster mannequin opened this issue Jun 8, 2016 · 4 comments
Labels
docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@ThiefMaster
Copy link
Mannequin

ThiefMaster mannequin commented Jun 8, 2016

BPO 27269
Nosy @socketpair, @ThiefMaster, @arp11
PRs
  • bpo-27269: Treat ::FFFF: addresses as IPv4 for ordering and contains. #1741
  • 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 = None
    closed_at = None
    created_at = <Date 2016-06-08.14:55:23.856>
    labels = ['type-bug', 'library', 'docs']
    title = 'ipaddress: Wrong behavior with ::ffff:1.2.3.4 style IPs'
    updated_at = <Date 2017-05-23.00:08:58.753>
    user = 'https://github.com/ThiefMaster'

    bugs.python.org fields:

    activity = <Date 2017-05-23.00:08:58.753>
    actor = 'arp11'
    assignee = 'docs@python'
    closed = False
    closed_date = None
    closer = None
    components = ['Documentation', 'Library (Lib)']
    creation = <Date 2016-06-08.14:55:23.856>
    creator = 'ThiefMaster'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 27269
    keywords = []
    message_count = 4.0
    messages = ['267861', '269984', '269986', '294198']
    nosy_count = 5.0
    nosy_names = ['pmoody', 'docs@python', 'socketpair', 'ThiefMaster', 'arp11']
    pr_nums = ['1741']
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue27269'
    versions = ['Python 3.5', 'Python 3.6']

    @ThiefMaster
    Copy link
    Mannequin Author

    ThiefMaster mannequin commented Jun 8, 2016

    I'd expect the IPv4 address to be considered part of that network (or actually parsed as an IPv4Address and not IPv6Address) even if it's written in IPv6 notation. It's an IPv4 after all.

    Python 3.5.1 (default, Jun  7 2016, 09:20:44)
    [GCC 4.9.3] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import ipaddress
    >>> ipaddress.ip_address('::ffff:127.0.0.1')
    IPv6Address('::ffff:7f00:1')
    >>> ipaddress.ip_address('::ffff:127.0.0.1') in ipaddress.ip_network('127.0.0.0/8')
    False
    >>> ipaddress.ip_address('127.0.0.1') in ipaddress.ip_network('127.0.0.0/8')
    True

    @ThiefMaster ThiefMaster mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jun 8, 2016
    @socketpair
    Copy link
    Mannequin

    socketpair mannequin commented Jul 8, 2016

    see also bpo-20446

    @socketpair
    Copy link
    Mannequin

    socketpair mannequin commented Jul 8, 2016

    Also, it should be marked explicitly, if cross-type lookup is safe. I mean code like that:

        some_net = ipaddress.ip_network(some_input1)
        some_addr = ipaddress.ip_address(some_input2)
        return some_addr in some_net

    Is it safe to write such code? Docs say:

    21.28.2.3. Operators
    Address objects support some operators. Unless stated otherwise,
    operators can only be applied between compatible objects
    (i.e. IPv4 with IPv4, IPv6 with IPv6).
    
    1. It is not said if exception will be raised if incompatible objects are used, and not said if result is defined.
    2. "Unless stated otherwise" - Seem it is stated nowhere.

    @socketpair socketpair mannequin added the docs Documentation in the Doc dir label Jul 8, 2016
    @socketpair socketpair mannequin assigned docspython Jul 8, 2016
    @arp11
    Copy link
    Mannequin

    arp11 mannequin commented May 22, 2017

    5cc2742

    ... seems to implement the principle in this bug, but I'm not convinced this is a good idea.

    @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
    docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    0 participants