[issue33784] hash collision in instances of ipaddress.ip_network
Francois Schneider added the comment: Thanks for the analysis, I agree completely. Actually the problem was coming from my code where one of the __eq__ method was implemented like this: >>> def __eq__(self, other): >>> return hash(self) == hash(other) so 2 instances with only a slight difference in their ip_network attribute (ip_network(u'20.0.2.3/32') and ip_network(u'20.0.2.0/30')) were having the same hash and being equal -> they could not be inserted both in the same collection. I will just rewrite my __eq__ method properly. -- status: pending -> open ___ Python tracker <https://bugs.python.org/issue33784> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33784] hash collision in instances of ipaddress.ip_network
New submission from Francois Schneider : >>> import ipaddress >>> hash(ipaddress.ip_network(u'20.0.2.3/32')) == >>> hash(ipaddress.ip_network(u'20.0.2.0/30')) True -- components: Library (Lib) messages: 318835 nosy: Francois Schneider priority: normal severity: normal status: open title: hash collision in instances of ipaddress.ip_network type: behavior versions: Python 2.7 ___ Python tracker <https://bugs.python.org/issue33784> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33784] hash collision in instances of ipaddress.ip_network
Change by Francois Schneider : -- versions: +Python 3.4, Python 3.5 ___ Python tracker <https://bugs.python.org/issue33784> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com