Skip to content

Commit c506403

Browse files
miss-islingtonMariatta
authored andcommitted
[3.6] bpo-31320: No traceback to sys.stderr in test_ssl (GH-3360) (GH-3369)
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]> (cherry picked from commit 305e56c)
1 parent 56b56e3 commit c506403

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Lib/test/test_ssl.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1843,11 +1843,14 @@ def wrap_conn(self):
18431843
self.sock, server_side=True)
18441844
self.server.selected_npn_protocols.append(self.sslconn.selected_npn_protocol())
18451845
self.server.selected_alpn_protocols.append(self.sslconn.selected_alpn_protocol())
1846-
except (ssl.SSLError, ConnectionResetError) as e:
1846+
except (ssl.SSLError, ConnectionResetError, OSError) as e:
18471847
# We treat ConnectionResetError as though it were an
18481848
# SSLError - OpenSSL on Ubuntu abruptly closes the
18491849
# connection when asked to use an unsupported protocol.
18501850
#
1851+
# OSError may occur with wrong protocols, e.g. both
1852+
# sides use PROTOCOL_TLS_SERVER.
1853+
#
18511854
# XXX Various errors can have happened here, for example
18521855
# a mismatching protocol version, an invalid certificate,
18531856
# or a low-level bug. This should be made more discriminating.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Silence traceback in test_ssl

0 commit comments

Comments
 (0)