This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Fix comparison of ipaddress classes
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: 21408 Superseder:
Assigned To: serhiy.storchaka Nosy List: ncoghlan, pmoody, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2015-01-18 20:02 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ipaddress_comparison.patch serhiy.storchaka, 2015-01-18 20:02 review
Messages (4)
msg234267 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-01-18 20:02
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.
msg234612 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2015-01-24 13:03
+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 #11477.

The fact the default __ne__ implementation doesn't handle NotImplemented correctly should probably be filed as a separate issue.
msg234617 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-01-24 15:07
> 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 issue21408.
msg234719 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-01-26 08:12
New changeset 9a7d965ab80f by Serhiy Storchaka in branch '3.4':
Issue #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 #23268: Fixed bugs in the comparison of ipaddress classes.
https://hg.python.org/cpython/rev/051f2a234d8a
History
Date User Action Args
2022-04-11 14:58:12adminsetgithub: 67457
2015-01-26 08:17:29serhiy.storchakasetstatus: open -> closed
assignee: serhiy.storchaka
resolution: fixed
stage: patch review -> resolved
2015-01-26 08:12:28python-devsetnosy: + python-dev
messages: + msg234719
2015-01-24 15:18:29serhiy.storchakasetdependencies: + delegation of `!=` to the right-hand side argument is not always done
2015-01-24 15:07:47serhiy.storchakasetmessages: + msg234617
2015-01-24 13:03:33ncoghlansetmessages: + msg234612
2015-01-18 20:02:38serhiy.storchakacreate