Skip to content

Commit d3ff80f

Browse files
authored
Update edit.py
1 parent bd0f247 commit d3ff80f

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎python_agent_harness/tools/edit.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import subprocess
1717

1818
from ..io.diffrender import unified_diff
19-
from .base import Tool, ToolContext
19+
from .base import Tool, ToolContext, atomic_write_text
2020

2121
# Any line ending, as a single compiled pattern (CRLF first so a CRLF is
2222
# never rewritten as two endings).
@@ -169,8 +169,7 @@ def _string_replace(self, path: str, old: str | None, new_str: str, ctx: ToolCon
169169
)
170170
new = content.replace(old, new_str, 1)
171171
try:
172-
with open(path, "w", encoding="utf-8", errors="surrogateescape", newline="") as f:
173-
f.write(new)
172+
atomic_write_text(path, new)
174173
except OSError as e:
175174
return f"Error: {e}"
176175
diff_text = unified_diff(content, new, path)

0 commit comments

Comments
 (0)