Skip to content

Commit 2d85edd

Browse files
committed
-
1 parent 1149343 commit 2d85edd

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

source_py2/python_toolbox/cute_iter_tools.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,10 @@ def are_equal(*sequences):
406406
if not sys_tools.is_pypy: # Hack around Pypy bug 1799
407407
# Trying cheap comparison:
408408
if len(sequence_types) == 1 and issubclass(
409-
get_single_if_any(sequence_types), collections.Sequence):
409+
get_single_if_any(sequence_types), collections.Sequence) and \
410+
not get_single_if_any(sequence_types) == xrange:
411+
# (Excluding `xrange` from this fast check because it has no
412+
# `__eq__`.)
410413

411414
return logic_tools.all_equal(sequences)
412415
# blocktodo: test on pypy and hopefully remove these two lines if not needed

source_py2/python_toolbox/sequence_tools/cute_range.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def __init__(self, *args):
135135

136136
__hash__ = lambda self: hash(self._reduced)
137137

138-
__eq__ = lambda self, other: (isinstance(other, CuteRange) and
138+
__eq__ = lambda self, other: (type(self) == type(other) and
139139
(self._reduced == other._reduced))
140140

141141
distance_to_cover = caching.CachedProperty(lambda self:

source_py3/python_toolbox/sequence_tools/cute_range.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def __init__(self, *args):
129129

130130
__hash__ = lambda self: hash(self._reduced)
131131

132-
__eq__ = lambda self, other: (isinstance(other, CuteRange) and
132+
__eq__ = lambda self, other: (type(self) == type(other) and
133133
(self._reduced == other._reduced))
134134

135135
distance_to_cover = caching.CachedProperty(lambda self:

0 commit comments

Comments
 (0)