summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_dict.py
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na92@gmail.com>2019-12-31 01:04:22 (GMT)
committerPablo Galindo <Pablogsal@gmail.com>2019-12-31 01:04:22 (GMT)
commit2d5bf568eaa5059402ccce9ba5a366986ba27c8a (patch)
tree04fe688caaa82e948cc4ff315fe82453f3445b6e /Lib/test/test_dict.py
parentee9ff05ec22ecd47dbffdd361967ccd55963dad2 (diff)
downloadcpython-2d5bf568eaa5059402ccce9ba5a366986ba27c8a.zip
cpython-2d5bf568eaa5059402ccce9ba5a366986ba27c8a.tar.gz
cpython-2d5bf568eaa5059402ccce9ba5a366986ba27c8a.tar.bz2
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_dict.py')
-rw-r--r--Lib/test/test_dict.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py
index 5b51376..de483ab 100644
--- a/Lib/test/test_dict.py
+++ b/Lib/test/test_dict.py
@@ -1221,7 +1221,7 @@ class DictTest(unittest.TestCase):
support.check_free_after_iterating(self, lambda d: iter(d.items()), dict)
def test_equal_operator_modifying_operand(self):
- # test fix for seg fault reported in issue 27945 part 3.
+ # test fix for seg fault reported in bpo-27945 part 3.
class X():
def __del__(self):
dict_b.clear()
@@ -1237,6 +1237,16 @@ class DictTest(unittest.TestCase):
dict_b = {X(): X()}
self.assertTrue(dict_a == dict_b)
+ # test fix for seg fault reported in bpo-38588 part 1.
+ class Y:
+ def __eq__(self, other):
+ dict_d.clear()
+ return True
+
+ dict_c = {0: Y()}
+ dict_d = {0: set()}
+ self.assertTrue(dict_c == dict_d)
+
def test_fromkeys_operator_modifying_dict_operand(self):
# test fix for seg fault reported in issue 27945 part 4a.
class X(int):