From f0a9469c7b64c4231c7f9a4934d8361f30144a2b Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 2 Oct 2025 16:25:20 +0200 Subject: [PATCH 1/2] gh-139504: Catch BrokenPipeError in ssl test_client_sigalgs_mismatch() --- Lib/test/test_ssl.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index d6e06445d53179..787a632836fe4b 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -4346,8 +4346,9 @@ def test_client_sigalgs_mismatch(self): client_context.set_client_sigalgs("rsa_pss_rsae_sha256") server_context.set_client_sigalgs("rsa_pss_rsae_sha384") - # Some systems return ConnectionResetError on handshake failures - with self.assertRaises((ssl.SSLError, ConnectionResetError)): + # gh-139504: Some systems return ConnectionResetError + # or BrokenPipeError on handshake failures + with self.assertRaises((ssl.SSLError, ConnectionResetError, BrokenPipeError)): server_params_test(client_context, server_context, chatty=True, connectionchatty=True, sni_name=hostname) From b7adf9737fbb339f4ee1b99447e550cf135f2bf7 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 2 Oct 2025 16:50:34 +0200 Subject: [PATCH 2/2] Update Lib/test/test_ssl.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> --- Lib/test/test_ssl.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index 787a632836fe4b..09de32f8371ae9 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -4346,9 +4346,14 @@ def test_client_sigalgs_mismatch(self): client_context.set_client_sigalgs("rsa_pss_rsae_sha256") server_context.set_client_sigalgs("rsa_pss_rsae_sha384") - # gh-139504: Some systems return ConnectionResetError - # or BrokenPipeError on handshake failures - with self.assertRaises((ssl.SSLError, ConnectionResetError, BrokenPipeError)): + with self.assertRaises(( + ssl.SSLError, + # On handshake failures, some systems raise a ConnectionResetError. + ConnectionResetError, + # On handshake failures, macOS may raise a BrokenPipeError. + # See https://github.com/python/cpython/issues/139504. + BrokenPipeError, + )): server_params_test(client_context, server_context, chatty=True, connectionchatty=True, sni_name=hostname)