Skip to content

Fix UnicodeEncodeError on cp1252 terminals (piped Windows output)#86

Merged
KaykCaputo merged 1 commit into
KaykCaputo:masterfrom
AnshBajpai05:fix/cp1252-output-crash
Jul 9, 2026
Merged

Fix UnicodeEncodeError on cp1252 terminals (piped Windows output)#86
KaykCaputo merged 1 commit into
KaykCaputo:masterfrom
AnshBajpai05:fix/cp1252-output-crash

Conversation

@AnshBajpai05

Copy link
Copy Markdown
Contributor

Companion small fix, independent of the XSS one (#85).

Symptom: on Windows, piping oracletrace output (oracletrace script.py > out.txt, CI logs, etc.) often lands on a cp1252 stream. If the traced code has recursion (the tree marker) or a comparison is printed (the arrow), the run dies with UnicodeEncodeError — after tracing already succeeded.

Fix: probe sys.stdout.encoding once; when the preferred char can't be encoded, fall back to ASCII (@ and ->).

Tests: unit tests for the fallback helper, plus an e2e test that forces PYTHONIOENCODING=cp1252 in a subprocess so the regression is caught on Linux CI too. The e2e crashes (exit 1, UnicodeEncodeError) on master and passes with the fix.

🤖 Generated with Claude Code

The recursion marker in the call tree and the arrow in comparison
output cannot be encoded by cp1252, the default encoding for piped
output on many Windows setups. The run then crashes with
UnicodeEncodeError after tracing already succeeded.

Fix: probe sys.stdout.encoding once and fall back to ASCII
equivalents (@ and ->) when the preferred char cannot be encoded.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@KaykCaputo KaykCaputo merged commit 6260ad3 into KaykCaputo:master Jul 9, 2026
4 checks passed
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.

2 participants