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

Fix comparison of ipaddress classes #67457

Closed
serhiy-storchaka opened this issue Jan 18, 2015 · 4 comments
Closed

Fix comparison of ipaddress classes #67457

serhiy-storchaka opened this issue Jan 18, 2015 · 4 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 23268
Nosy @ncoghlan, @serhiy-storchaka
Dependencies
  • bpo-21408: delegation of != to the right-hand side argument is not always done
  • Files
  • ipaddress_comparison.patch
  • 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/serhiy-storchaka'
    closed_at = <Date 2015-01-26.08:17:29.047>
    created_at = <Date 2015-01-18.20:02:38.720>
    labels = ['type-bug', 'library']
    title = 'Fix comparison of ipaddress classes'
    updated_at = <Date 2015-01-26.08:17:29.046>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2015-01-26.08:17:29.046>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2015-01-26.08:17:29.047>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2015-01-18.20:02:38.720>
    creator = 'serhiy.storchaka'
    dependencies = ['21408']
    files = ['37767']
    hgrepos = []
    issue_num = 23268
    keywords = ['patch']
    message_count = 4.0
    messages = ['234267', '234612', '234617', '234719']
    nosy_count = 4.0
    nosy_names = ['ncoghlan', 'pmoody', 'python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue23268'
    versions = ['Python 3.4', 'Python 3.5']

    @serhiy-storchaka
    Copy link
    Member Author

    Here is a patch which fixes following errors in comparison of ipaddress classes.

    1. Ordering comparison raised AttributeError when compared with foreign classes.

    2. Ordering comparison didn't return NotImplemented when compared with foreign classes. This prevented fallback to foreign class comparison method.

    3. There was a bug in _TotalOrderingMixin.__le__(). It could return False instead of NotImplemented if compared network and address of different versions.

    4. There was a typo in ComparisonTests.test_incompatible_versions().

    As far as functools.total_ordering now is fixed and more correct and tested than _TotalOrderingMixin, _TotalOrderingMixin is dropped away.

    @serhiy-storchaka serhiy-storchaka added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jan 18, 2015
    @ncoghlan
    Copy link
    Contributor

    +1, looks good to me.

    That test for ordering and comparison interoperability is actually pretty neat - I wonder if we could make it more generally available as a "check my class handles NotImplemented correctly" check (in unittest?), which would potentially be useful in pursuing a fix for issue bpo-11477.

    The fact the default __ne__ implementation doesn't handle NotImplemented correctly should probably be filed as a separate issue.

    @serhiy-storchaka
    Copy link
    Member Author

    The fact the default __ne__ implementation doesn't handle NotImplemented correctly should probably be filed as a separate issue.

    May be this is a part of bpo-21408.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jan 26, 2015

    New changeset 9a7d965ab80f by Serhiy Storchaka in branch '3.4':
    Issue bpo-23268: Fixed bugs in the comparison of ipaddress classes.
    https://hg.python.org/cpython/rev/9a7d965ab80f

    New changeset 051f2a234d8a by Serhiy Storchaka in branch 'default':
    Issue bpo-23268: Fixed bugs in the comparison of ipaddress classes.
    https://hg.python.org/cpython/rev/051f2a234d8a

    @serhiy-storchaka serhiy-storchaka self-assigned this Jan 26, 2015
    @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
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants