mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Issue #1766304: The range.__contains__ optimization should only be
applied to ints, not to instances of subclasses of int.
This commit is contained in:
parent
067b38eed4
commit
418f81d9b6
2 changed files with 7 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue