Git Product home page Git Product logo

Comments (4)

GoogleCodeExporter avatar GoogleCodeExporter commented on May 5, 2024
I'm removing the first testHash. turns out that __hash__ is platform an version 
dependent so testing that __hash__ returns a particular integer isn't even 
fragile, it's 
broken.

Original comment by [email protected] on 7 Oct 2009 at 2:55

  • Changed state: Fixed

from ipaddr-py.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 5, 2024
True, but the failure was (at least on my system Vista64, py25 for win32) that 
has(IPv6Netowrk('2001:658:22a:cafe:200:0:0:1/64').network) == 
(IPv6Network('2001:658:22a:cafe:200:0:0:1/64').broadcast)

which would mean the Network has a range of 0, but there are in fact IP's in 
there 
when you loop over the network, so that points is a bug in the _BaseIP.__hash__ 
method.

I just did some further testing
>>> ipv6 = IPv6Network('2001:658:22a:cafe:200:0:0:1/64')
>>> print ipv6.network._ip == ipv6.broadcast._ip
False
>>> print hash(ipv6.network) == hash(ipv6.broadcast)
True
>>> print ipv6.network == ipv6.broadcast
False

The current _BaseIP.__hash__ just does hash(self._ip) which in this particular 
case 
means the two different longs are hashing equal at the python level. After some 
testing I propose the __hash__ be changed to hash(hex(self._ip)) or 
hash(self._string_from_ip_int(self._ip))

Original comment by [email protected] on 7 Oct 2009 at 3:23

from ipaddr-py.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 5, 2024
fair enough. I'll check out making hash use the hex() value.

Original comment by [email protected] on 7 Oct 2009 at 3:33

  • Changed state: Accepted

from ipaddr-py.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 5, 2024
r121

Original comment by [email protected] on 9 Oct 2009 at 4:24

  • Changed state: Fixed

from ipaddr-py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.