diff --git a/sot/opcode_translator/executor/opcode_executor.py b/sot/opcode_translator/executor/opcode_executor.py index bc82f051c..7c79023f9 100644 --- a/sot/opcode_translator/executor/opcode_executor.py +++ b/sot/opcode_translator/executor/opcode_executor.py @@ -422,7 +422,7 @@ def __init__(self, code: types.CodeType, graph: FunctionGraph): self._code = code self._instructions = get_instructions(self._code) self._graph = graph - self._current_line: int | None = None + self._current_line: int = -1 self.new_code: types.CodeType | None = None self.guard_fn = None self._name = "Executor" @@ -527,15 +527,16 @@ def error_message_summary(original_error: Exception) -> str: message_lines = ["In simulate execution:", ""] for current_simulator in OpcodeExecutorBase.call_stack: code = current_simulator._code - current_line = current_simulator._current_line or 0 + current_line = current_simulator._current_line lines, start = inspect.getsourcelines(code) real_name = code.co_name message_lines.append( f"{indent} File \"{code.co_filename}\", line {current_line}, in {real_name}" ) - message_lines.append( - f"{indent} {lines[current_line-start].rstrip()}" - ) + if current_line != -1: + message_lines.append( + f"{indent} {lines[current_line-start].rstrip()}" + ) error_message = traceback.format_exception_only( type(original_error), original_error ) diff --git a/sot/opcode_translator/executor/side_effects.py b/sot/opcode_translator/executor/side_effects.py index 9494dfe7e..9c71571f6 100644 --- a/sot/opcode_translator/executor/side_effects.py +++ b/sot/opcode_translator/executor/side_effects.py @@ -39,8 +39,8 @@ def get_proxy( def get_state(self): return SideEffectsState( - self.data_id_to_proxy, - self.variables, + self.data_id_to_proxy.copy(), + self.variables.copy(), [proxy.version for proxy in self.data_id_to_proxy.values()], ) diff --git a/sot/opcode_translator/instruction_utils/instruction_utils.py b/sot/opcode_translator/instruction_utils/instruction_utils.py index e1aa77b86..8a2c67759 100644 --- a/sot/opcode_translator/instruction_utils/instruction_utils.py +++ b/sot/opcode_translator/instruction_utils/instruction_utils.py @@ -254,7 +254,7 @@ def calc_offset_from_bytecode_offset(bytecode_offset: int) -> int: def replace_instr(instructions, instr, new_instr): idx = instructions.index(instr) - instructions[idx, idx + 1] = new_instr + instructions[idx : idx + 1] = new_instr def instrs_info(instrs, mark=None):