Hardcode the list of attributes to be used in comparison

Comparing Range subclasses may lead to surprises.
This commit is contained in:
Daniele Varrazzo 2014-02-22 21:52:44 +00:00
parent 4545d1636c
commit 8937c635df

View File

@ -140,7 +140,7 @@ class Range(object):
def __lt__(self, other): def __lt__(self, other):
if not isinstance(other, Range): if not isinstance(other, Range):
return NotImplemented return NotImplemented
for attr in self.__slots__: for attr in ('_lower', '_upper', '_bounds'):
self_value = getattr(self, attr) self_value = getattr(self, attr)
other_value = getattr(other, attr) other_value = getattr(other, attr)
if self_value == other_value: if self_value == other_value: