]> granicus.if.org Git - python/commitdiff
bpo-31320: No traceback to sys.stderr in test_ssl (#3360)
authorChristian Heimes <christian@python.org>
Tue, 5 Sep 2017 23:37:09 +0000 (16:37 -0700)
committerGitHub <noreply@github.com>
Tue, 5 Sep 2017 23:37:09 +0000 (16:37 -0700)
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 <christian@python.org>
Lib/test/test_ssl.py
Misc/NEWS.d/next/Tests/2017-09-05-14-23-35.bpo-31320.JRDHx7.rst [new file with mode: 0644]

index 5916a2bcf160ec11bbe8462450b40041d05759ce..a8ffef0944f9f19bf2411af1b082bd0e0cfad21d 100644 (file)
@@ -1853,11 +1853,14 @@ if _have_threads:
                         self.sock, server_side=True)
                     self.server.selected_npn_protocols.append(self.sslconn.selected_npn_protocol())
                     self.server.selected_alpn_protocols.append(self.sslconn.selected_alpn_protocol())
-                except (ssl.SSLError, ConnectionResetError) as e:
+                except (ssl.SSLError, ConnectionResetError, OSError) as e:
                     # We treat ConnectionResetError as though it were an
                     # SSLError - OpenSSL on Ubuntu abruptly closes the
                     # connection when asked to use an unsupported protocol.
                     #
+                    # OSError may occur with wrong protocols, e.g. both
+                    # sides use PROTOCOL_TLS_SERVER.
+                    #
                     # XXX Various errors can have happened here, for example
                     # a mismatching protocol version, an invalid certificate,
                     # or a low-level bug. This should be made more discriminating.
diff --git a/Misc/NEWS.d/next/Tests/2017-09-05-14-23-35.bpo-31320.JRDHx7.rst b/Misc/NEWS.d/next/Tests/2017-09-05-14-23-35.bpo-31320.JRDHx7.rst
new file mode 100644 (file)
index 0000000..8b7163d
--- /dev/null
@@ -0,0 +1 @@
+Silence traceback in test_ssl