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 c10c1186a5
commit 6c27cdd20e

View File

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