diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2004-08-13 03:18:29 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2004-08-13 03:18:29 (GMT) |
commit | f076953eb13caf629c81c3656cc0f178c7a91b1d (patch) | |
tree | 0a433a11cc30bd1ef3cd9bc1d7b026ee88a29235 /Lib/test/list_tests.py | |
parent | 39689c5c6a2a3f1a9135d62b427032a3c4eae053 (diff) | |
download | cpython-f076953eb13caf629c81c3656cc0f178c7a91b1d.zip cpython-f076953eb13caf629c81c3656cc0f178c7a91b1d.tar.gz cpython-f076953eb13caf629c81c3656cc0f178c7a91b1d.tar.bz2 |
SF patch #1005778, Fix seg fault if list object is modified during list.index()
Backport candidate
Diffstat (limited to 'Lib/test/list_tests.py')
-rw-r--r-- | Lib/test/list_tests.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/list_tests.py b/Lib/test/list_tests.py index d20d198..1233ad1 100644 --- a/Lib/test/list_tests.py +++ b/Lib/test/list_tests.py @@ -311,6 +311,18 @@ class CommonTest(seq_tests.CommonTest): self.assertRaises(ValueError, a.index, 2, 0, 4) self.assertEqual(a, self.type2test([-2, -1, 0, 1, 2])) + # Test modifying the list during index's iteration + class EvilCmp: + def __init__(self, victim): + self.victim = victim + def __eq__(self, other): + del self.victim[:] + return False + a = self.type2test() + a[:] = [EvilCmp(a) for _ in xrange(100)] + # This used to seg fault before patch #1005778 + self.assertRaises(ValueError, a.index, None) + def test_reverse(self): u = self.type2test([-2, -1, 0, 1, 2]) u2 = u[:] |