Add explicit encoding="utf-8" to all config/data file open() calls
On Windows, open() defaults to the system locale encoding (cp1252, cp1254, etc.) rather than UTF-8. This breaks any file containing non-ASCII characters, and also causes crashes when writing JSON with ensure_ascii=False. This adds encoding="utf-8" to open() calls in: - gateway/run.py (config.yaml reads/writes throughout) - gateway/config.py (gateway.json and config.yaml) - hermes_cli/config.py (config.yaml load/save) - hermes_cli/main.py (session export with ensure_ascii=False) - hermes_cli/status.py (jobs.json and sessions.json)
This commit is contained in:
parent
21d61bdd71
commit
81986022b7
5 changed files with 28 additions and 28 deletions
|
|
@ -260,7 +260,7 @@ def load_gateway_config() -> GatewayConfig:
|
|||
gateway_config_path = Path.home() / ".hermes" / "gateway.json"
|
||||
if gateway_config_path.exists():
|
||||
try:
|
||||
with open(gateway_config_path, "r") as f:
|
||||
with open(gateway_config_path, "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
config = GatewayConfig.from_dict(data)
|
||||
except Exception as e:
|
||||
|
|
@ -273,7 +273,7 @@ def load_gateway_config() -> GatewayConfig:
|
|||
import yaml
|
||||
config_yaml_path = Path.home() / ".hermes" / "config.yaml"
|
||||
if config_yaml_path.exists():
|
||||
with open(config_yaml_path) as f:
|
||||
with open(config_yaml_path, encoding="utf-8") as f:
|
||||
yaml_cfg = yaml.safe_load(f) or {}
|
||||
sr = yaml_cfg.get("session_reset")
|
||||
if sr and isinstance(sr, dict):
|
||||
|
|
@ -411,5 +411,5 @@ def save_gateway_config(config: GatewayConfig) -> None:
|
|||
gateway_config_path = Path.home() / ".hermes" / "gateway.json"
|
||||
gateway_config_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
with open(gateway_config_path, "w") as f:
|
||||
with open(gateway_config_path, "w", encoding="utf-8") as f:
|
||||
json.dump(config.to_dict(), f, indent=2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue