Skip to content

Commit 305e56c

Browse files
authored
bpo-31320: No traceback to sys.stderr in test_ssl (#3360)
In case PROTOCOL_TLS_SERVER is used for both client context and server context, the test thread dies with OSError. Catch OSError to avoid traceback on sys.stderr Signed-off-by: Christian Heimes <[email protected]>
1 parent 60dbed1 commit 305e56c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Lib/test/test_ssl.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1853,11 +1853,14 @@ def wrap_conn(self):
18531853
self.sock, server_side=True)
18541854
self.server.selected_npn_protocols.append(self.sslconn.selected_npn_protocol())
18551855
self.server.selected_alpn_protocols.append(self.sslconn.selected_alpn_protocol())
1856-
except (ssl.SSLError, ConnectionResetError) as e:
1856+
except (ssl.SSLError, ConnectionResetError, OSError) as e:
18571857
# We treat ConnectionResetError as though it were an
18581858
# SSLError - OpenSSL on Ubuntu abruptly closes the
18591859
# connection when asked to use an unsupported protocol.
18601860
#
1861+
# OSError may occur with wrong protocols, e.g. both
1862+
# sides use PROTOCOL_TLS_SERVER.
1863+
#
18611864
# XXX Various errors can have happened here, for example
18621865
# a mismatching protocol version, an invalid certificate,
18631866
# or a low-level bug. This should be made more discriminating.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Silence traceback in test_ssl

0 commit comments

Comments
 (0)