summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_range.py
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-09-24 20:04:23 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-09-24 20:04:23 (GMT)
commit418f81d9b65ca2c7942ff9c422ad01d5050a808f (patch)
treea2e1fabc0af6fad77c1142badf29227c0f9bdd43 /Lib/test/test_range.py
parent067b38eed41bc659ab3d3f9d780a824ed5d1b857 (diff)
downloadcpython-418f81d9b65ca2c7942ff9c422ad01d5050a808f.zip
cpython-418f81d9b65ca2c7942ff9c422ad01d5050a808f.tar.gz
cpython-418f81d9b65ca2c7942ff9c422ad01d5050a808f.tar.bz2
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.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_range.py b/Lib/test/test_range.py
index 1a40dd1..638d943 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)