Skip to content

SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]

Fix(tools): Default to utf-8 encoding when writing

Kilian Lieret1690f9b8ae5c
diff --git a/tools/edit_anthropic/bin/str_replace_editor b/tools/edit_anthropic/bin/str_replace_editor
index 32c10de1..a04a07ca 100644
--- a/tools/edit_anthropic/bin/str_replace_editor
+++ b/tools/edit_anthropic/bin/str_replace_editor
@@ -656,7 +656,7 @@ class EditTool:
def write_file(self, path: Path, file: str):
"""Write the content of a file to a given path; raise a ToolError if an error occurs."""
try:
- path.write_text(file, encoding=self._encoding)
+ path.write_text(file, encoding=self._encoding or "utf-8")
except Exception as e:
print(f"Ran into {e} while trying to write to {path}")
sys.exit(20)