-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
ipaddress.ip_interface __lt__ check seems to be broken #74117
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
Comments
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. |
Indeed, this looks as a bug. >>> a < b
False
>>> b > a
True |
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. |
I think we should backport this to at least 3.6. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: