diff --git a/sot/opcode_translator/executor/opcode_executor.py b/sot/opcode_translator/executor/opcode_executor.py index 466b7c485..c23e8d28d 100644 --- a/sot/opcode_translator/executor/opcode_executor.py +++ b/sot/opcode_translator/executor/opcode_executor.py @@ -1766,7 +1766,6 @@ def FOR_ITER(self, instr): if not isinstance( iterator, (SequenceIterVariable, DictIterVariable) ): - self._graph.remove_global_guarded_variable(iterator) raise BreakGraphError() backup_iter_idx = iterator.idx self._inline_call_for_loop(iterator, instr) @@ -1774,6 +1773,7 @@ def FOR_ITER(self, instr): except BreakGraphError as e: if backup_iter_idx: iterator.idx = backup_iter_idx + self._graph.remove_global_guarded_variable(iterator) self._break_graph_in_for_loop(iterator, instr) return Stop()