Skip to content

The agent that grows with you

fix(update): bind the restore fd before os.fdopen so the footgun gate sees binary mode

Tekniumef32fcb257d4
diff --git a/hermes_cli/update_cmd_commit.py b/hermes_cli/update_cmd_commit.py
index b5fd053db12..e8e9d015733 100644
--- a/hermes_cli/update_cmd_commit.py
+++ b/hermes_cli/update_cmd_commit.py
@@ -118,7 +118,8 @@ def disarm_commit_obligations() -> None:
# A fresh file, never through whatever a leftover ``.restore`` name points at.
tmp = path.with_name(f".{path.name}.{os.getpid()}.restore")
tmp.unlink(missing_ok=True)
- with os.fdopen(os.open(tmp, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600), "wb") as handle:
+ fd = os.open(tmp, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600)
+ with os.fdopen(fd, "wb") as handle:
handle.write(data)
os.replace(tmp, path)
except OSError: