Repository navigation
Conversation
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
|
🤖 Written by Claude Opus 5.5 via Claude Code for the pytest maintainers; I prompted it, it did the work, I read it. This makes #4389 is about code that acts on the attribute. With import sys
def test_it(capsys):
sys.stdout.buffer.write("café\n".encode(sys.stdout.encoding))
sys.stdout.flush()
assert capsys.readouterr().out == "café\n"
The attribute and the codec have to agree. That means building the capture stream with the replaced stream's Generated by Claude Code |
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
for more information, see https://pre-commit.ci
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Thanks, I think this addresses your concern. Could you also rerun the ubuntu-pypy3-xdist and ubuntu-py315 jobs? The PyPy job failed in |
Captured
sys.stdoutandsys.stderrnow use the encoding and error handler of the streams they replace. When either setting is missing or is not a string, capture falls back to UTF-8 andstrict.Text writes use those settings. Bytes written directly through
.bufferare decoded using the selected encoding when captured output is read back, with undecodable bytes replaced.stdincapture is unchanged. Binary fixtures still return bytes; text written through them is encoded with the replaced streams' encoding and error handler.Closes #4389.