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.

Author Sanjay
Recipients Sanjay
Date 2017-03-27.07:23:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1490599415.99.0.717154213111.issue29913@psf.upfronthosting.co.za>
In-reply-to
Content
according to the docs compare_networks only checks the network address but the implementation is also taking the mask length into account. It returns '0' only if both the network address and the mask are equal but this can be done with just equality check ( ip1 == ip2 )

Example:
>>> ip1=ipaddress.ip_network("1.1.1.0/24")
>>> ip2=ipaddress.ip_network("1.1.1.0/25")
>>> ip1.compare_networks(ip2)
-1
>>> ip1 == ip2
False
>>> ip1.network_address
IPv4Address('1.1.1.0')
>>> ip2.network_address
IPv4Address('1.1.1.0')
>>> 

shouldn't we ignore the mask length ? I have tried it here:

https://github.com/s-sanjay/cpython/commit/942073c1ebd29891e047b5e784750c2b6f74494a
History
Date User Action Args
2017-03-27 07:23:36Sanjaysetrecipients: + Sanjay
2017-03-27 07:23:35Sanjaysetmessageid: <1490599415.99.0.717154213111.issue29913@psf.upfronthosting.co.za>
2017-03-27 07:23:35Sanjaylinkissue29913 messages
2017-03-27 07:23:35Sanjaycreate