Commit 63711818 authored by Xavier Thompson's avatar Xavier Thompson

Fix cypclass dict item deletion invalidating active iterators

parent 84e0507e
......@@ -286,6 +286,7 @@ cdef cypclass cypdict[K, V]:
it = self._indices.find(key)
end = self._indices.end()
if it != end:
if self._active_iterators == 0:
index = dereference(it).second
Cy_DECREF(self._items[index].first)
Cy_DECREF(self._items[index].second)
......@@ -293,6 +294,9 @@ cdef cypclass cypdict[K, V]:
if index < self._items.size() - 1:
self._items[index] = self._items[self._indices.size() - 1]
self._items.pop_back()
else:
with gil:
raise RuntimeError("Modifying a dictionary with active iterators")
else:
with gil:
raise KeyError("Deleting nonexistent item")
......
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