From 20a28ac513bd8cba8983b33039cf7edc9a05330e Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 23 Oct 2026 00:47:43 +0000 Subject: [PATCH] Tolerate PyPy's SSLError("Broken pipe") in the SSL echo server's unwrap The test echo server suppresses BrokenPipeError when the client has already gone away before the server's unwrap(). PyPy's _cffi_ssl reports that same EPIPE as a plain ssl.SSLError("Broken pipe"), so test_send_all_empty_string flaked on PyPy. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VPZoDDtuKy1bbLLR2nsnmW --- src/trio/_tests/test_ssl.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/trio/_tests/test_ssl.py b/src/trio/_tests/test_ssl.py index 2a1dc3d487..bb61ac563b 100644 --- a/src/trio/_tests/test_ssl.py +++ b/src/trio/_tests/test_ssl.py @@ -121,8 +121,14 @@ def ssl_echo_serve_sync( # other side has initiated a graceful shutdown; we try to # respond in kind but it's legal for them to have already # gone away. - with suppress(BrokenPipeError, ssl.SSLZeroReturnError): - wrapped.unwrap() + try: + with suppress(BrokenPipeError, ssl.SSLZeroReturnError): + wrapped.unwrap() + except ssl.SSLError as unwrap_exc: # pragma: no cover + # PyPy reports EPIPE here as SSLError("Broken pipe") + # rather than BrokenPipeError. + if "Broken pipe" not in str(unwrap_exc): + raise return wrapped.sendall(data) # This is an obscure workaround for an openssl bug. In server mode, in