Skip to content

SR-5: escape unencodable characters in the stdout wrapper - #325

Draft
jothimani-rajendran wants to merge 2 commits into
mainfrom
sr-5-stdout-encoding
Draft

jothimani-rajendran wants to merge 2 commits into
mainfrom
sr-5-stdout-encoding

Conversation

@jothimani-rajendran

@jothimani-rajendran jothimani-rajendran commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

What

PipeTolerantWriter.write retries with backslashreplace in the stream's encoding when the write raises UnicodeEncodeError (IR-F18: chock check on a Windows runner, stdout cp1252, crashed on U+FFFD while printing eval results). Both writes go through the same broken-pipe handling.

Scope

  • src/chock/pipe.py, tests/test_pipe_tolerance.py, one changelog fragment.
  • Text the encoding can represent is written unchanged (covered by a test).
  • Vendored runtime / .chock/ untouched.

Test

test_unencodable_character_is_escaped_not_raised writes U+FFFD through the wrapper onto a cp1252 TextIOWrapper; it failed with UnicodeEncodeError before the change and passes after. test_broken_pipe_on_the_escaped_retry_is_tolerated covers a reader that closes during the escaped retry.

A cp1252 stdout raised UnicodeEncodeError on U+FFFD. Retry with backslashreplace in
the stream encoding; representable text is unchanged.

Signed-off-by: Jothi Mani Rajendran <250249270+jothimani-rajendran@users.noreply.github.com>
Both writes now go through the same OSError handling, so a reader that vanishes
during the backslashreplace retry no longer raises past the wrapper.

Signed-off-by: Jothi Mani Rajendran <250249270+jothimani-rajendran@users.noreply.github.com>

Copy link
Copy Markdown
Collaborator Author

validate (ubuntu-latest, 3.12) failed on 975abcc in tests/test_pattern_deadline.py::test_the_judge_matches_times_out_and_reports_a_dead_child (budget.judge_patterns reported "no verdict within 1s" where the test expects "exited early"). It is a 1s-timeout test of budget.py, which this diff does not touch (src/chock/pipe.py only); the same job passed on 3.11 for this commit and test_pipe_tolerance.py passed. No fix to port exists yet. Re-running the failed job once; a second failure will be treated as real.


Generated by Claude Code

This branch has not been deployed

No deployments
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