summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-02-09 08:39:28 (GMT)
committerGitHub <noreply@github.com>2020-02-09 08:39:28 (GMT)
commitdc56f5f48866bf3c5412642bba00890d9a090cfb (patch)
tree83fc2ed841921df70c8bb38d9951f93aa537261d /Lib/test
parent0c915e620d049558bacc78cf25c1560f55d1fb82 (diff)
downloadcpython-dc56f5f48866bf3c5412642bba00890d9a090cfb.zip
cpython-dc56f5f48866bf3c5412642bba00890d9a090cfb.tar.gz
cpython-dc56f5f48866bf3c5412642bba00890d9a090cfb.tar.bz2
bpo-39590: make deque.__contains__ and deque.count hold strong references (GH-18421) (GH-18423)
(cherry picked from commit c6dedde160a9fce5d049e860f586ad8f93aec822) Co-authored-by: sweeneyde <36520290+sweeneyde@users.noreply.github.com> Co-authored-by: sweeneyde <36520290+sweeneyde@users.noreply.github.com>
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_deque.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_deque.py b/Lib/test/test_deque.py
index 51b66b7..c0f7138 100644
--- a/Lib/test/test_deque.py
+++ b/Lib/test/test_deque.py
@@ -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)