mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
bpo-39590: make deque.__contains__ and deque.count hold strong references (GH-18421)
This commit is contained in:
parent
7f6f7eef52
commit
c6dedde160
3 changed files with 17 additions and 0 deletions
|
|
@ -183,6 +183,18 @@ class TestBasic(unittest.TestCase):
|
|||
with self.assertRaises(RuntimeError):
|
||||
n in d
|
||||
|
||||
def test_contains_count_stop_crashes(self):
|
||||
class A:
|
||||
def __eq__(self, other):
|
||||
d.clear()
|
||||
return NotImplemented
|
||||
d = deque([A(), A()])
|
||||
with self.assertRaises(RuntimeError):
|
||||
_ = 3 in d
|
||||
d = deque([A(), A()])
|
||||
with self.assertRaises(RuntimeError):
|
||||
_ = d.count(3)
|
||||
|
||||
def test_extend(self):
|
||||
d = deque('a')
|
||||
self.assertRaises(TypeError, d.extend, 1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue