diff options
author | Dong-hee Na <donghee.na92@gmail.com> | 2019-12-31 10:04:22 +0900 |
---|---|---|
committer | Pablo Galindo <Pablogsal@gmail.com> | 2019-12-31 01:04:22 +0000 |
commit | 2d5bf568eaa5059402ccce9ba5a366986ba27c8a (patch) | |
tree | 04fe688caaa82e948cc4ff315fe82453f3445b6e /Lib/test/test_list.py | |
parent | ee9ff05ec22ecd47dbffdd361967ccd55963dad2 (diff) | |
download | cpython-git-2d5bf568eaa5059402ccce9ba5a366986ba27c8a.tar.gz |
bpo-38588: Fix possible crashes in dict and list when calling PyObject_RichCompareBool (GH-17734)
Take strong references before calling PyObject_RichCompareBool to protect against the case
where the object dies during the call.
Diffstat (limited to 'Lib/test/test_list.py')
-rw-r--r-- | Lib/test/test_list.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_list.py b/Lib/test/test_list.py index b10a833033..6e3c4c1093 100644 --- a/Lib/test/test_list.py +++ b/Lib/test/test_list.py @@ -163,6 +163,31 @@ class ListTest(list_tests.CommonTest): with self.assertRaises(TypeError): (3,) + L([1,2]) + def test_equal_operator_modifying_operand(self): + # test fix for seg fault reported in bpo-38588 part 2. + class X: + def __eq__(self,other) : + list2.clear() + return NotImplemented + + class Y: + def __eq__(self, other): + list1.clear() + return NotImplemented + + class Z: + def __eq__(self, other): + list3.clear() + return NotImplemented + + list1 = [X()] + list2 = [Y()] + self.assertTrue(list1 == list2) + + list3 = [Z()] + list4 = [1] + self.assertFalse(list3 == list4) + @cpython_only def test_preallocation(self): iterable = [0] * 10 |