Mercurial > cpython-lru_cache-weakref
diff Lib/test/test_range.py @ 56210:0f4e95ff859d
Issue #1766304: The range.__contains__ optimization should only be
applied to ints, not to instances of subclasses of int.
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Thu, 24 Sep 2009 20:04:23 +0000 |
| parents | d599a3f2e72d |
| children | 370d218a01bc |
line wrap: on
line diff
--- a/Lib/test/test_range.py Thu Sep 24 19:24:44 2009 +0000 +++ b/Lib/test/test_range.py Thu Sep 24 20:04:23 2009 +0000 @@ -97,6 +97,12 @@ # ..except if explicitly told so. self.assertTrue(int(C2()) in range(3)) + # Check that the range.__contains__ optimization is only + # used for ints, not for instances of subclasses of int. + class C3(int): + def __eq__(self, other): return True + self.assertTrue(C3(11) in range(10)) + self.assertTrue(C3(11) in list(range(10))) def test_strided_limits(self): r = range(0, 101, 2)
