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.ip_interface __lt__ check seems to be broken #74117

Closed
s-sanjay mannequin opened this issue Mar 28, 2017 · 7 comments
Closed

ipaddress.ip_interface __lt__ check seems to be broken #74117

s-sanjay mannequin opened this issue Mar 28, 2017 · 7 comments
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@s-sanjay
Copy link
Mannequin

s-sanjay mannequin commented Mar 28, 2017

BPO 29931
Nosy @ncoghlan, @berkerpeksag, @serhiy-storchaka, @zhangyangyu, @Mariatta, @s-sanjay
PRs
  • bpo-29931 fix __lt__ check in ipaddress.ip_interface for both v4 and v6. #879
  • [3.6] bpo-29931 fix __lt__ check in ipaddress.ip_interface for both v4 and v6. (GH-879) #2217
  • [3.5] bpo-29931 fix __lt__ check in ipaddress.ip_interface for both v4 and v6. (GH-879) #2218
  • 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 = <Date 2017-06-15.14:17:26.165>
    created_at = <Date 2017-03-28.10:37:20.702>
    labels = ['3.7', 'type-bug', 'library']
    title = 'ipaddress.ip_interface __lt__ check seems to be broken'
    updated_at = <Date 2017-06-15.14:17:26.164>
    user = 'https://github.com/s-sanjay'

    bugs.python.org fields:

    activity = <Date 2017-06-15.14:17:26.164>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-06-15.14:17:26.165>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2017-03-28.10:37:20.702>
    creator = 'Sanjay'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 29931
    keywords = []
    message_count = 7.0
    messages = ['290695', '290700', '290964', '291112', '291684', '296098', '296099']
    nosy_count = 7.0
    nosy_names = ['ncoghlan', 'pmoody', 'berker.peksag', 'serhiy.storchaka', 'xiang.zhang', 'Mariatta', 'Sanjay']
    pr_nums = ['879', '2217', '2218']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue29931'
    versions = ['Python 3.5', 'Python 3.6', 'Python 3.7']

    @s-sanjay
    Copy link
    Mannequin Author

    s-sanjay mannequin commented Mar 28, 2017

    The less than check for ip_interface behavior seems weird. I am not sure if this is by design. We are just comparing the network address but when network address is equal we should compare the ip address.
    The expectation is if a < b is False then b <= a must be True
    >>> import ipaddress
    >>> a = ipaddress.ip_interface("1.1.1.1/24")
    >>> b = ipaddress.ip_interface("1.1.1.2/24")
    >>> a < b
    False
    >>> b <= a
    False
    >>> a == b
    False
    >>> 
    This happens with both v4 and v6
    The tests were passing because in ComparisonTests we were testing with prefix length of 32 which means the whole ip address became the network address.
    I have made a fix here:
    https://github.com/s-sanjay/cpython/commit/14975f58539308b7af5a1519705fb8cd95ad7951
    I can add more tests and send PR but before that I wanted to confirm the behavior.

    @s-sanjay s-sanjay mannequin added 3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Mar 28, 2017
    @serhiy-storchaka
    Copy link
    Member

    Indeed, this looks as a bug.

    >>> a < b
    False
    >>> b > a
    True

    @serhiy-storchaka
    Copy link
    Member

    New changeset 7bd8d3e by Serhiy Storchaka (s-sanjay) in branch 'master':
    bpo-29931 fix __lt__ check in ipaddress.ip_interface for both v4 and v6. (#879)
    7bd8d3e

    @Mariatta
    Copy link
    Member

    Mariatta commented Apr 4, 2017

    Serhiy, just checking whether this needs backport? The PR has the backport to 3.5 and 3.6 labels, but it's not indicated in this ticket.
    If it doesn't need backport, then perhaps we can close this issue.
    Thanks.

    @berkerpeksag
    Copy link
    Member

    I think we should backport this to at least 3.6.

    @serhiy-storchaka
    Copy link
    Member

    New changeset cf58dfb by Serhiy Storchaka in branch '3.6':
    [3.6] bpo-29931 fix __lt__ check in ipaddress.ip_interface for both v4 and v6. (GH-879) (bpo-2217)
    cf58dfb

    @serhiy-storchaka
    Copy link
    Member

    New changeset c5a6fb6 by Serhiy Storchaka in branch '3.5':
    [3.5] bpo-29931 fix __lt__ check in ipaddress.ip_interface for both v4 and v6. (GH-879) (bpo-2218)
    c5a6fb6

    @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.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants