bpo-39453: Make list.__contains__ hold strong references to avoid crashes (GH-18181)

This commit is contained in:
Dong-hee Na 2020-01-28 00:02:23 +09:00 committed by Pablo Galindo
parent a46575a8f2
commit 4dbf2d8c67
3 changed files with 13 additions and 1 deletions

View file

@ -221,6 +221,11 @@ class ListTest(list_tests.CommonTest):
with self.assertRaises(ValueError):
lst.remove(lst)
# bpo-39453: list.__contains__ was not holding strong references
# to list elements while calling PyObject_RichCompareBool().
lst = [X(), X()]
3 in lst
if __name__ == "__main__":
unittest.main()