mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-30 01:41:43 +00:00
Merge PR #458: Add explicit UTF-8 encoding to config/data file I/O
Authored by shitcoinsherpa. Adds encoding='utf-8' to all text-mode open() calls in gateway/run.py, gateway/config.py, hermes_cli/config.py, hermes_cli/main.py, and hermes_cli/status.py. Prevents encoding errors on Windows where the default locale is not UTF-8. Also fixed 4 additional open() calls in gateway/run.py that were added after the PR branch was created.
This commit is contained in:
commit
36328a996f
6 changed files with 51 additions and 48 deletions
|
|
@ -757,9 +757,9 @@ def load_config() -> Dict[str, Any]:
|
|||
|
||||
if config_path.exists():
|
||||
try:
|
||||
with open(config_path) as f:
|
||||
with open(config_path, encoding="utf-8") as f:
|
||||
user_config = yaml.safe_load(f) or {}
|
||||
|
||||
|
||||
config = _deep_merge(config, user_config)
|
||||
except Exception as e:
|
||||
print(f"Warning: Failed to load config: {e}")
|
||||
|
|
@ -802,7 +802,7 @@ def save_config(config: Dict[str, Any]):
|
|||
ensure_hermes_home()
|
||||
config_path = get_config_path()
|
||||
|
||||
with open(config_path, 'w') as f:
|
||||
with open(config_path, 'w', encoding="utf-8") as f:
|
||||
yaml.dump(config, f, default_flow_style=False, sort_keys=False)
|
||||
# Append commented-out sections for features that are off by default
|
||||
# or only relevant when explicitly configured. Skip sections the
|
||||
|
|
@ -1077,7 +1077,7 @@ def set_config_value(key: str, value: str):
|
|||
user_config = {}
|
||||
if config_path.exists():
|
||||
try:
|
||||
with open(config_path) as f:
|
||||
with open(config_path, encoding="utf-8") as f:
|
||||
user_config = yaml.safe_load(f) or {}
|
||||
except Exception:
|
||||
user_config = {}
|
||||
|
|
@ -1105,7 +1105,7 @@ def set_config_value(key: str, value: str):
|
|||
|
||||
# Write only user config back (not the full merged defaults)
|
||||
ensure_hermes_home()
|
||||
with open(config_path, 'w') as f:
|
||||
with open(config_path, 'w', encoding="utf-8") as f:
|
||||
yaml.dump(user_config, f, default_flow_style=False, sort_keys=False)
|
||||
|
||||
# Keep .env in sync for keys that terminal_tool reads directly from env vars.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue