Skip to content

fix: Windows encoding crash in HelixVisualizer.render()#28

Merged
jkbennitt merged 2 commits into
mainfrom
fix/windows-encoding
Mar 21, 2026
Merged

fix: Windows encoding crash in HelixVisualizer.render()#28
jkbennitt merged 2 commits into
mainfrom
fix/windows-encoding

Conversation

@jkbennitt
Copy link
Copy Markdown
Member

Summary

Fixes UnicodeEncodeError when HelixVisualizer.render() writes Unicode block characters on Windows (cp1252 default encoding).

Fix

  • render() calls sys.stdout.reconfigure(encoding='utf-8') before writing
  • Falls back to sys.stdout.buffer.write(output.encode('utf-8')) if UnicodeEncodeError still occurs
  • New test verifies the fallback path with a mocked stdout

Also

  • Cleaned up lint warnings across all test files (36 issues: unused imports, unused variables, lambda-to-def)
  • Version bump: 0.2.0 -> 0.2.1

Test plan

  • 824 tests passing
  • ruff check src/ tests/ clean
  • New test for encoding fallback
  • Verified on Windows without PYTHONIOENCODING

jkbennitt and others added 2 commits March 21, 2026 16:39
render() now reconfigures stdout to UTF-8 and falls back to
buffer.write(utf-8 bytes) when sys.stdout.write() raises
UnicodeEncodeError on Windows cp1252.

Also: clean up lint warnings across all test files (unused imports,
unused variables, lambda-to-def).

Bump to v0.2.1.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
io.UnsupportedOperation (subclass of OSError) can occur on some
redirected/piped stdout. Catch alongside AttributeError.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jkbennitt
Copy link
Copy Markdown
Member Author

Code Review — Approve

Fixed: reconfigure guard now catches OSError (covers io.UnsupportedOperation on redirected streams) alongside AttributeError.

824 tests passing, ruff clean. LGTM.

@jkbennitt jkbennitt merged commit 74fffc8 into main Mar 21, 2026
@jkbennitt jkbennitt deleted the fix/windows-encoding branch March 25, 2026 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant