Merged from trunk 11465:11467
authorFabian Groffen <grobian@gentoo.org>
Sun, 24 Aug 2008 17:39:14 +0000 (17:39 -0000)
committerFabian Groffen <grobian@gentoo.org>
Sun, 24 Aug 2008 17:39:14 +0000 (17:39 -0000)
   | 11466   | Avoid possible AttributeError raised from                    |
   | zmedico | _ObjectKey.__eq__().                                         |

   | 11467   | * Fix broken _ObjectKey.__eq__() logic from previous commit. |
   | zmedico | * Define _ObjectKey.__slots__ to save memory.                |

svn path=/main/branches/prefix/; revision=11468

pym/portage/dbapi/vartree.py

index 0a8f82a7a2909dcd2766fa9ae08f09ce21e5ba21..c1aba2a9c5bb6cbf32ca7d41089e97391940c021 100644 (file)
@@ -153,6 +153,8 @@ class LinkageMap(object):
 
                """Helper class used as _obj_properties keys for objects."""
 
+               __slots__ = ("__weakref__", "_key")
+
                def __init__(self, object):
                        """
                        This takes a path to an object.
@@ -167,7 +169,11 @@ class LinkageMap(object):
                        return hash(self._key)
 
                def __eq__(self, other):
-                       return self._key == other._key
+                       if isinstance(other, self.__class__):
+                               other_key = other._key
+                       else:
+                               other_key = other
+                       return self._key == other_key
 
                def _generate_object_key(self, object):
                        """