Fix UnicodeEncodeError on cp1252 terminals (piped Windows output)#86
Merged
KaykCaputo merged 1 commit intoJul 9, 2026
Merged
Conversation
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
approved these changes
Jul 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 withUnicodeEncodeError— after tracing already succeeded.Fix: probe
sys.stdout.encodingonce; 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=cp1252in 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