# HG changeset patch # User Julien Cristau # Date 1441728297 -7200 # Node ID e6eb0c7c2e98162ebcc15bd25fbc92634e3ad4ee # Parent 97f6b3d655fc0e6b0d7bb6a5db7caf548c9b9bef implement __ne__ whenever we implement __eq__ diff -r 97f6b3d655fc -r e6eb0c7c2e98 schema.py --- a/schema.py Tue Sep 08 17:15:03 2015 +0200 +++ b/schema.py Tue Sep 08 18:04:57 2015 +0200 @@ -253,6 +253,9 @@ return self.expression == other.expression return False + def __ne__(self, other): + return not (self == other) + def __hash__(self): return hash(self.expression) diff -r 97f6b3d655fc -r e6eb0c7c2e98 server/edition.py --- a/server/edition.py Tue Sep 08 17:15:03 2015 +0200 +++ b/server/edition.py Tue Sep 08 18:04:57 2015 +0200 @@ -38,7 +38,7 @@ class EditedEntity(dict): """encapsulate entities attributes being written by an RQL query""" def __init__(self, entity, **kwargs): - dict.__init__(self, **kwargs) + super(EditedEntity, self).__init__(**kwargs) self.entity = entity self.skip_security = set() self.querier_pending_relations = {} @@ -50,10 +50,13 @@ def __lt__(self, other): # we don't want comparison by value inherited from dict - return id(self) < id(other) + raise NotImplementedError def __eq__(self, other): - return id(self) == id(other) + return self is other + + def __ne__(self, other): + return not (self == other) def __setitem__(self, attr, value): assert attr != 'eid' diff -r 97f6b3d655fc -r e6eb0c7c2e98 utils.py --- a/utils.py Tue Sep 08 17:15:03 2015 +0200 +++ b/utils.py Tue Sep 08 18:04:57 2015 +0200 @@ -208,8 +208,10 @@ if isinstance(other, RepeatList): return other._size == self._size and other._item == self._item return self[:] == other - # py3k future warning "Overriding __eq__ blocks inheritance of __hash__ in 3.x" - # is annoying but won't go away because we don't want to hash() the repeatlist + def __ne__(self, other): + return not (self == other) + def __hash__(self): + raise NotImplementedError def pop(self, i): self._size -= 1