summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-08-24 21:14:20 +0000
committerZac Medico <zmedico@gentoo.org>2008-08-24 21:14:20 +0000
commit5474659211db6936a4c1224c8e0e891c26f3f190 (patch)
treeed1d1de26be6212b72790ad3849f868debab53de
parent547d765a2f9b553bf62e1b84ac3ce4fb20049743 (diff)
downloadportage-5474659211db6936a4c1224c8e0e891c26f3f190.tar.gz
portage-5474659211db6936a4c1224c8e0e891c26f3f190.tar.bz2
portage-5474659211db6936a4c1224c8e0e891c26f3f190.zip
Fix _ObjectKey.__eq__() to account for potential hash collisions that would
break dict behavior. Thanks to Lucian Poston for spotting this. svn path=/main/trunk/; revision=11473
-rw-r--r--pym/portage/dbapi/vartree.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index 598845e0b..2c030c13c 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -169,11 +169,12 @@ class LinkageMap(object):
return hash(self._key)
def __eq__(self, other):
- if isinstance(other, self.__class__):
- other_key = other._key
- else:
- other_key = other
- return self._key == other_key
+ if not isinstance(other, self.__class__):
+ # Can't safely return True in this case since
+ # if there is a hash collision then __eq__ needs
+ # to be relied upon for correct dict behavior.
+ return False
+ return self._key == other._key
def _generate_object_key(self, object):
"""