diff --git a/spacy/pipeline/_parser_internals/arc_eager.pyx b/spacy/pipeline/_parser_internals/arc_eager.pyx index ddcc911c8..029e2e29e 100644 --- a/spacy/pipeline/_parser_internals/arc_eager.pyx +++ b/spacy/pipeline/_parser_internals/arc_eager.pyx @@ -604,7 +604,7 @@ cdef class ArcEager(TransitionSystem): actions[SHIFT][''] += 1 if min_freq is not None: for action, label_freqs in actions.items(): - for label, freq in list(label_freqs.items()): + for label, freq in label_freqs.copy().items(): if freq < min_freq: label_freqs.pop(label) # Ensure these actions are present diff --git a/spacy/vectors.pyx b/spacy/vectors.pyx index 6d6783af4..1b985a638 100644 --- a/spacy/vectors.pyx +++ b/spacy/vectors.pyx @@ -274,7 +274,7 @@ cdef class Vectors: self.data = resized_array self._sync_unset() removed_items = [] - for key, row in list(self.key2row.items()): + for key, row in self.key2row.copy().items(): if row >= shape[0]: self.key2row.pop(key) removed_items.append((key, row))