Allow destructive ops during son iteration

and let python handle (identical to iter on list)
This commit is contained in:
Don Mitchell 2014-06-04 17:40:32 -04:00 committed by A. Jesse Jiryu Davis
parent 01b499850c
commit 26f3f40fc9
2 changed files with 0 additions and 11 deletions

View File

@ -120,13 +120,7 @@ class SON(dict):
# efficient.
# second level definitions support higher levels
def __iter__(self):
"""
Cannot remove nor add keys while iterating
"""
key_len = len(self.__keys)
for k in self.__keys:
if len(self.__keys) != key_len:
raise RuntimeError("son changed length during iteration")
yield k
def has_key(self, key):

View File

@ -163,11 +163,6 @@ class TestSON(unittest.TestCase):
test_son = SON([(1, 100), (2, 200), (3, 300)])
for ele in test_son:
self.assertEqual(ele * 100, test_son[ele])
# test failure case
def break_iter():
for ele in test_son:
del test_son[ele]
self.assertRaises(RuntimeError, break_iter)
def test_contains_has(self):
"""