* [gentoo-commits] portage r11473 - main/trunk/pym/portage/dbapi
@ 2008-08-24 21:14 Zac Medico (zmedico)
0 siblings, 0 replies; only message in thread
From: Zac Medico (zmedico) @ 2008-08-24 21:14 UTC (permalink / raw
To: gentoo-commits
Author: zmedico
Date: 2008-08-24 21:14:20 +0000 (Sun, 24 Aug 2008)
New Revision: 11473
Modified:
main/trunk/pym/portage/dbapi/vartree.py
Log:
Fix _ObjectKey.__eq__() to account for potential hash collisions that would
break dict behavior. Thanks to Lucian Poston for spotting this.
Modified: main/trunk/pym/portage/dbapi/vartree.py
===================================================================
--- main/trunk/pym/portage/dbapi/vartree.py 2008-08-24 19:50:47 UTC (rev 11472)
+++ main/trunk/pym/portage/dbapi/vartree.py 2008-08-24 21:14:20 UTC (rev 11473)
@@ -169,11 +169,12 @@
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):
"""
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-08-24 21:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-24 21:14 [gentoo-commits] portage r11473 - main/trunk/pym/portage/dbapi Zac Medico (zmedico)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox