mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
bpo-36473: add maximum iteration check for dict .values() and .items() (GH-12619)
This commit is contained in:
parent
04694a306b
commit
b8311cf5e5
3 changed files with 36 additions and 2 deletions
|
|
@ -477,7 +477,25 @@ class DictTest(unittest.TestCase):
|
|||
with self.assertRaises(RuntimeError):
|
||||
for i in d:
|
||||
del d[0]
|
||||
d[1] = 1
|
||||
d[0] = 0
|
||||
|
||||
def test_mutating_iteration_delete_over_values(self):
|
||||
# change dict content during iteration
|
||||
d = {}
|
||||
d[0] = 0
|
||||
with self.assertRaises(RuntimeError):
|
||||
for i in d.values():
|
||||
del d[0]
|
||||
d[0] = 0
|
||||
|
||||
def test_mutating_iteration_delete_over_items(self):
|
||||
# change dict content during iteration
|
||||
d = {}
|
||||
d[0] = 0
|
||||
with self.assertRaises(RuntimeError):
|
||||
for i in d.items():
|
||||
del d[0]
|
||||
d[0] = 0
|
||||
|
||||
def test_mutating_lookup(self):
|
||||
# changing dict during a lookup (issue #14417)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue