Skip to content

fix: add encoding='utf-8' to os.fdopen() and open() text-mode calls - #51766

Closed
AlexFucuson9 wants to merge 1 commit into
NousResearch:mainfrom
AlexFucuson9:fix/add-encoding-fdopen
Closed

fix: add encoding='utf-8' to os.fdopen() and open() text-mode calls#51766
AlexFucuson9 wants to merge 1 commit into
NousResearch:mainfrom
AlexFucuson9:fix/add-encoding-fdopen

Conversation

@AlexFucuson9

Copy link
Copy Markdown
Contributor

What

Add encoding='utf-8' to os.fdopen() and open() calls in text mode that omitted it.

Why

On Windows with non-UTF-8 locale, the default encoding is the system locale. Writing UTF-8 content without explicit encoding causes UnicodeEncodeError.

Complements PR #51748/#51752/#51761 (read_text/write_text) and #51406 (initial fdopen batch).

Changes (4 files, 6 lines)

File Change
agent/nous_rate_guard.py os.fdopen(fd, 'w') → add encoding
agent/shell_hooks.py os.fdopen(fd, 'w') → add encoding
gateway/slash_commands.py open(exit_code_path, 'w') → add encoding
hermes_cli/config.py os.fdopen(fd, 'w', **write_kw) → add encoding

Add encoding='utf-8' to os.fdopen() and open() calls in text mode
that omitted it. On Windows with non-UTF-8 locale, the default
encoding is the system locale, causing UnicodeEncodeError on write.

4 files, 6 lines changed:
- agent/nous_rate_guard.py: os.fdopen(fd, 'w')
- agent/shell_hooks.py: os.fdopen(fd, 'w')
- gateway/slash_commands.py: open(exit_code_path, 'w')
- hermes_cli/config.py: 3x os.fdopen(fd, 'w', **write_kw)
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows P3 Low — cosmetic, nice to have labels Jun 24, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related: this is a superset of #51406 (which patches the two agent/ fdopen sites + gateway/slash_commands.py). This PR adds the hermes_cli/config.py fdopen sites on top. Same Windows non-UTF-8-locale encoding family as #51406 / #51308 / #18782 — maintainer may prefer to consolidate. Not a duplicate (broader scope).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants