Comments (4)
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.
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.
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.
r121
Original comment by [email protected]
on 9 Oct 2009 at 4:24
- Changed state: Fixed
from ipaddr-py.
Related Issues (20)
- IPv4Network __getitem__ does not return update network ips when IPv4Network.ip is changed
- Support for rfc6598 space in IPv4Network/Address.is_private HOT 3
- Sorting ips with different versions: TypeError: are not of the same version HOT 3
- IPv*Interface objects in the same network but different addresses hash to the same value and compare as equal HOT 1
- Link-Local IPv6 Unicast Addresses should be fe80::/64 instead of fe80::/10
- IPAddress/IPNetwork objects not picklable HOT 1
- Google drive limitation :( HOT 3
- Add support for ipv6 addresses that are wrapped in '[<ipv6]' HOT 1
- Patch: Construct networks with (ip, prefixlen) tuples HOT 3
- README insufficiency
- I think IPNetwork objects should have a len() method (really __len__ I suppose) HOT 2
- Add support for changing the prefixlen on existing objects HOT 1
- code.google.com usage HOT 2
- Incorrect SVN export HOT 10
- plans for Python 3.x support? HOT 2
- "ip_int=0L" variable have a extra string in ipaddr.py HOT 2
- pypi broken HOT 4
- pypi does not have working python 3 version HOT 4
- ipaddr.IPv6Network("fc00:101:0:3::/56").subnet(new_prefix = 64) BUG
- Respectful code cleanup HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ipaddr-py.