Commit 927a7dbf authored by Xavier Thompson's avatar Xavier Thompson

Fix exception handling on updating cypclass dict

parent d965b9a3
...@@ -170,7 +170,7 @@ cdef cypclass cypdict[K, V]: ...@@ -170,7 +170,7 @@ cdef cypclass cypdict[K, V]:
self._items[index] = self._items[self._indices.size() - 1] self._items[index] = self._items[self._indices.size() - 1]
self._items.pop_back() self._items.pop_back()
void update(self, const cypdict[K, V] other): void update(self, const cypdict[K, V] other) except ~:
for item in other.items(): for item in other.items():
self[item.first] = item.second self[item.first] = item.second
......
...@@ -377,6 +377,25 @@ def test_clear_iterator_invalidation(): ...@@ -377,6 +377,25 @@ def test_clear_iterator_invalidation():
print(e) print(e)
return 0 return 0
def test_update_iterator_invalidation():
"""
>>> test_update_iterator_invalidation()
Modifying a dictionary with active iterators
0
"""
d = cypdict[Index, Value]()
d2 = cypdict[Index, Value]()
d2[Index(1)] = Value(1)
iterator = d.begin()
try:
with nogil:
d.update(d2)
with gil:
return -1
except RuntimeError as e:
print(e)
return 0
def test_modification_after_dict_iterator(): def test_modification_after_dict_iterator():
""" """
>>> test_modification_after_dict_iterator() >>> test_modification_after_dict_iterator()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment