diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2009-09-24 20:04:23 +0000 |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2009-09-24 20:04:23 +0000 |
commit | fcb5484facf913e9033f40b89396f53b6823adb2 (patch) | |
tree | c076a0a265969475ed850bc6663618f239bdd33a /Lib/test/test_range.py | |
parent | b6f9dce03c789e58a0739aa76a3923b22a53570f (diff) | |
download | cpython-fcb5484facf913e9033f40b89396f53b6823adb2.tar.gz |
Issue #1766304: The range.__contains__ optimization should only be
applied to ints, not to instances of subclasses of int.
Diffstat (limited to 'Lib/test/test_range.py')
-rw-r--r-- | Lib/test/test_range.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_range.py b/Lib/test/test_range.py index 1a40dd1296..638d94377c 100644 --- a/Lib/test/test_range.py +++ b/Lib/test/test_range.py @@ -97,6 +97,12 @@ class RangeTest(unittest.TestCase): # ..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) |